尝试运行Grails应用程序时出错 [英] Error trying to run a Grails app

查看:151
本文介绍了尝试运行Grails应用程序时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Grails的新手,我使用GVM工具安装了它,我试图从终端运行一个默认应用程序,试试这个命令:grails create-app demo然后grails run-app, m得到一个巨大的错误:

  |运行Grails应用程序
|错误2013-12-02 02:41:59,628 [localhost-startStop-1]错误context.GrailsContextLoader - 初始化应用程序时出错:创建名为'transactionManagerPostProcessor'的bean时出错:Bean初始化失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'transactionManager'的bean时出错:无法在设置bean属性'sessionFactory'时解析对bean'sessionFactory'的引用;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套异常是org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException:无法确定数据库名称的Hibernate方言[H2]!
消息:创建名为'transactionManagerPostProcessor'的bean时出错:bean初始化失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'transactionManager'的bean时出错:无法在设置bean属性'sessionFactory'时解析对bean'sessionFactory'的引用;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套异常是org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException:无法确定数据库名称的Hibernate方言[H2]!
Line |方法
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中
导致BeanCreationException:创建名为'transactionManager'的bean时出错:无法在设置bean属性'sessionFactory'时解析对bean'sessionFactory'的引用。嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套异常是org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException:无法确定数据库名称的Hibernate方言[H2]!
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中引入
由BeanCreationException引发:创建名为'sessionFactory'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套异常是org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException:无法确定数据库名称的Hibernate方言[H2]!
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中引入
由BeanCreationException引发:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套异常是org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException:无法确定数据库名称的Hibernate方言[H2]!
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中
由BeanCreationException引发:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套异常是org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException:无法确定数据库名称的Hibernate方言[H2]!
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中
由CouldNotDetermineHibernateDialectException引发:无法确定数据库名称的Hibernate方言[H2]!
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread
|中错误分叉Grails VM退出,错误
|服务器运行。浏览到http:// localhost:8080 / demo

我的java版本:

  java版本1.7.0_25
OpenJDK运行环境(IcedTea 2.3.10)(7u25-2.3.10-1ubuntu0.13.04.2 )
OpenJDK Server VM(构建23.7-b01,混合模式)

我的grails版本:

  Grails版本:2.3.3 

此外,还有DataSource.groovy用于我试图运行的默认应用程序。

  dataSource {
pooled = true
driverClassName =org.h2.Driver
username =sa
password =
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class ='net.sf.ehcache.hibernate.EhCacheRegionFactory'// Hibernate 3
// cache.region.factory_class ='org.hibernate.cache.ehcache.EhCacheRegionFactory'// Hibernate 4
}

// env特定设置
{
development {
dataSource {
dbCreate =create-drop// //创建,创建,删除,更新'validate',''
url =jdbc:h2:mem:devDb; MVCC = TRUE; LOCK_TIMEOUT = 10000; DB_CLOSE_ON_EXIT = FALSE
}
}
test {
dataSource {
dbCreate =update
url =jdbc:h2:mem:testDb; MVCC = TRUE; LOCK_TIMEOUT = 10000; DB_CLOSE_ON_EXIT = FALSE
}
}
production {
dataSource {
dbCreate =update
url =jdbc:h2:prodDb; MVCC = TRUE; LOCK_TIMEOUT = 10000; DB_CLOSE_ON_EXIT = FALSE
properties {
maxActive = -1
minEvictableIdleTimeMillis = 1800000
timeBetweenEvictionRunsMillis = 1800000
numTestsPerEvictionRun = 3
testOnBorrow = true
te stWhileIdle = true
testOnReturn = false
validationQuery =SELECT 1
jdbcInterceptors =ConnectionState
}
}
}
}

编辑:
问题解决了,只需升级JDK版本即可。

解决方案

您需要安装 Grails H2插件。添加

  compile:h2:0.2.6
插件中 $ c> block。


I'm new with Grails, I installed it with the GVM tool and I'm trying to run a default application from a terminal, just try this commands: grails create-app demo and then grails run-app, I'm getting a massive error:

| Running Grails application
| Error 2013-12-02 02:41:59,628 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
    Line | Method
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.codehaus.groovy.grails.orm.hibernate.exceptions.CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by CouldNotDetermineHibernateDialectException: Could not determine Hibernate dialect for database name [H2]!
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
| Error Forked Grails VM exited with error
| Server running. Browse to http://localhost:8080/demo

My java version:

java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
OpenJDK Server VM (build 23.7-b01, mixed mode)

My grails version:

Grails version: 2.3.3

Also, there's the DataSource.groovy for the default application that i'm trying to run

dataSource {
    pooled = true
    driverClassName = "org.h2.Driver"
    username = "sa"
    password = ""
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
//    cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
}

// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
        }
    }
    test {
        dataSource {
            dbCreate = "update"
            url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
        }
    }
    production {
        dataSource {
            dbCreate = "update"
            url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
            properties {
               maxActive = -1
               minEvictableIdleTimeMillis=1800000
               timeBetweenEvictionRunsMillis=1800000
               numTestsPerEvictionRun=3
               testOnBorrow=true
               testWhileIdle=true
               testOnReturn=false
               validationQuery="SELECT 1"
               jdbcInterceptors="ConnectionState"
            }
        }
    }
} 

EDIT: Problem solved, just upgrade the JDK version.

解决方案

You need to install the Grails H2 plugin. Add

compile ":h2:0.2.6"

to grails-app/conf/BuildConfig.groovy, in the plugins block.

这篇关于尝试运行Grails应用程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆