Java 在 tomcat 上部署 grails 应用程序时,创建名为“transactionManagerPostProcessor”的 bean 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18548933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error creating bean with name 'transactionManagerPostProcessor' while deploying grails application on tomcat
提问by rahulserver
I am trying to deploy my grails(2.2.1) application on tomcat 7.0.42. So I followed the steps as given in this linkfrom grails website. But when I try to start the application from Tomcat Web Application Manager, I see the following error log on the tomcat console:
我正在尝试在 tomcat 7.0.42 上部署我的 grails(2.2.1) 应用程序。所以我按照grails 网站的这个链接中给出的步骤操作。但是当我尝试从 Tomcat Web Application Manager 启动应用程序时,我在 tomcat 控制台上看到以下错误日志:
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.fa
ctory.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.springframew
ork.beans.factory.BeanCreationException: Error creating bean with name 'dialectD
etector': Invocation of init method failed; nested exception is org.springframew
ork.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaDat
a; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (Database may be already in use: "Locked by another p
rocess". Possible solutions: close all other connection(s); use the server mode
[90020-164])
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'transactionManagerPostProcessor': Initialization of bean failed; nested
exception is org.springframework.beans.factory.BeanCreationException: Error crea
ting bean with name 'transactionManager': Cannot resolve reference to bean 'sess
ionFactory' while setting bean property 'sessionFactory'; nested exception is or
g.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' wh
ile setting bean property 'hibernateProperties'; nested exception is org.springf
ramework.beans.factory.BeanCreationException: Error creating bean with name 'hib
ernateProperties': Cannot resolve reference to bean 'dialectDetector' while sett
ing bean property 'properties' with key [hibernate.dialect]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean wi
th name 'dialectDetector': Invocation of init method failed; nested exception is
org.springframework.jdbc.support.MetaDataAccessException: Error while extractin
g DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedExcepti
on: Cannot create PoolableConnectionFactory (Database may be already in use: "Lo
cked by another process". Possible solutions: close all other connection(s); use
the server mode [90020-164])
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'transactionManager': Cannot resolve reference to bean 'sessio
nFactory' while setting bean property 'sessionFactory'; nested exception is org.
springframework.beans.factory.BeanCreationException: Error creating bean with na
me 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' whil
e setting bean property 'hibernateProperties'; nested exception is org.springfra
mework.beans.factory.BeanCreationException: Error creating bean with name 'hiber
nateProperties': Cannot resolve reference to bean 'dialectDetector' while settin
g bean property 'properties' with key [hibernate.dialect]; nested exception is o
rg.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'dialectDetector': Invocation of init method failed; nested exception is o
rg.springframework.jdbc.support.MetaDataAccessException: Error while extracting
DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException
: Cannot create PoolableConnectionFactory (Database may be already in use: "Lock
ed by another process". Possible solutions: close all other connection(s); use t
he server mode [90020-164])
... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateP
roperties' while setting bean property 'hibernateProperties'; nested exception i
s org.springframework.beans.factory.BeanCreationException: Error creating bean w
ith name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetecto
r' while setting bean property 'properties' with key [hibernate.dialect]; nested
exception is org.springframework.beans.factory.BeanCreationException: Error cre
ating bean with name 'dialectDetector': Invocation of init method failed; nested
exception is org.springframework.jdbc.support.MetaDataAccessException: Error wh
ile extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQL
NestedException: Cannot create PoolableConnectionFactory (Database may be alread
y in use: "Locked by another process". Possible solutions: close all other conne
ction(s); use the server mode [90020-164])
... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'hibernateProperties': Cannot resolve reference to bean 'diale
ctDetector' 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 faile
d; nested exception is org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting DatabaseMetaData; nested exception is org.apache.commons
.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Database may
be already in use: "Locked by another process". Possible solutions: close all ot
her connection(s); use the server mode [90020-164])
... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'dialectDetector': Invocation of init method failed; nested ex
ception is org.springframework.jdbc.support.MetaDataAccessException: Error while
extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNes
tedException: Cannot create PoolableConnectionFactory (Database may be already i
n use: "Locked by another process". Possible solutions: close all other connecti
on(s); use the server mode [90020-164])
... 3 more
Caused by: org.springframework.jdbc.support.MetaDataAccessException: Error while
extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNes
tedException: Cannot create PoolableConnectionFactory (Database may be already i
n use: "Locked by another process". Possible solutions: close all other connecti
on(s); use the server mode [90020-164])
... 3 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableCon
nectionFactory (Database may be already in use: "Locked by another process". Pos
sible solutions: close all other connection(s); use the server mode [90020-164])
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFacto
ry(BasicDataSource.java:1549)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:1044)
... 3 more
Caused by: org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked
by another process". Possible solutions: close all other connection(s); use the
server mode [90020-164]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.store.FileLock.getExceptionAlreadyInUse(FileLock.java:439)
at org.h2.store.FileLock.lockFile(FileLock.java:336)
at org.h2.store.FileLock.lock(FileLock.java:128)
at org.h2.engine.Database.open(Database.java:542)
at org.h2.engine.Database.openDatabase(Database.java:222)
at org.h2.engine.Database.<init>(Database.java:217)
at org.h2.engine.Engine.openSession(Engine.java:56)
at org.h2.engine.Engine.openSession(Engine.java:159)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:138)
at org.h2.engine.Engine.createSession(Engine.java:121)
at org.h2.engine.Engine.createSession(Engine.java:28)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.jav
a:305)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:72)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(Driv
erConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(Poolable
ConnectionFactory.java:582)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(Bas
icDataSource.java:1556)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFacto
ry(BasicDataSource.java:1545)
... 5 more
2013-08-31 19:17:32,185 [http-apr-8081-exec-4] ERROR context.GrailsContextLoader
- Error initializing Grails: Error creating bean with name 'transactionManager
PostProcessor': Initialization of bean failed; nested exception is org.springfra
mework.beans.factory.BeanCreationException: Error creating bean with name 'trans
actionManager': Cannot resolve reference to bean 'sessionFactory' while setting
bean property 'sessionFactory'; nested exception is org.springframework.beans.fa
ctory.BeanCreationException: Error creating bean with name 'sessionFactory': Can
not resolve reference to bean 'hibernateProperties' while setting bean property
'hibernateProperties'; nested exception is org.springframework.beans.factory.Bea
nCreationException: Error creating bean with name 'hibernateProperties': Cannot
resolve reference to bean 'dialectDetector' while setting bean property 'propert
ies' 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.springframework.jdbc.
support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested
exception is org.apache.commons.dbcp.SQLNestedException: Cannot create Poolable
ConnectionFactory (Database may be already in use: "Locked by another process".
Possible solutions: close all other connection(s); use the server mode [90020-16
4])
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'transactionManagerPostProcessor': Initialization of bean failed; nested
exception is org.springframework.beans.factory.BeanCreationException: Error crea
ting bean with name 'transactionManager': Cannot resolve reference to bean 'sess
ionFactory' while setting bean property 'sessionFactory'; nested exception is or
g.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' wh
ile setting bean property 'hibernateProperties'; nested exception is org.springf
ramework.beans.factory.BeanCreationException: Error creating bean with name 'hib
ernateProperties': Cannot resolve reference to bean 'dialectDetector' while sett
ing bean property 'properties' with key [hibernate.dialect]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean wi
th name 'dialectDetector': Invocation of init method failed; nested exception is
org.springframework.jdbc.support.MetaDataAccessException: Error while extractin
g DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedExcepti
on: Cannot create PoolableConnectionFactory (Database may be already in use: "Lo
cked by another process". Possible solutions: close all other connection(s); use
the server mode [90020-164])
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'transactionManager': Cannot resolve reference to bean 'sessio
nFactory' while setting bean property 'sessionFactory'; nested exception is org.
springframework.beans.factory.BeanCreationException: Error creating bean with na
me 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' whil
e setting bean property 'hibernateProperties'; nested exception is org.springfra
mework.beans.factory.BeanCreationException: Error creating bean with name 'hiber
nateProperties': Cannot resolve reference to bean 'dialectDetector' while settin
g bean property 'properties' with key [hibernate.dialect]; nested exception is o
rg.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'dialectDetector': Invocation of init method failed; nested exception is o
rg.springframework.jdbc.support.MetaDataAccessException: Error while extracting
DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException
: Cannot create PoolableConnectionFactory (Database may be already in use: "Lock
ed by another process". Possible solutions: close all other connection(s); use t
he server mode [90020-164])
... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateP
roperties' while setting bean property 'hibernateProperties'; nested exception i
s org.springframework.beans.factory.BeanCreationException: Error creating bean w
ith name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetecto
r' while setting bean property 'properties' with key [hibernate.dialect]; nested
exception is org.springframework.beans.factory.BeanCreationException: Error cre
ating bean with name 'dialectDetector': Invocation of init method failed; nested
exception is org.springframework.jdbc.support.MetaDataAccessException: Error wh
ile extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQL
NestedException: Cannot create PoolableConnectionFactory (Database may be alread
y in use: "Locked by another process". Possible solutions: close all other conne
ction(s); use the server mode [90020-164])
... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'hibernateProperties': Cannot resolve reference to bean 'diale
ctDetector' 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 faile
d; nested exception is org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting DatabaseMetaData; nested exception is org.apache.commons
.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Database may
be already in use: "Locked by another process". Possible solutions: close all ot
her connection(s); use the server mode [90020-164])
... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'dialectDetector': Invocation of init method failed; nested ex
ception is org.springframework.jdbc.support.MetaDataAccessException: Error while
extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNes
tedException: Cannot create PoolableConnectionFactory (Database may be already i
n use: "Locked by another process". Possible solutions: close all other connecti
on(s); use the server mode [90020-164])
... 3 more
Caused by: org.springframework.jdbc.support.MetaDataAccessException: Error while
extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNes
tedException: Cannot create PoolableConnectionFactory (Database may be already i
n use: "Locked by another process". Possible solutions: close all other connecti
on(s); use the server mode [90020-164])
... 3 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableCon
nectionFactory (Database may be already in use: "Locked by another process". Pos
sible solutions: close all other connection(s); use the server mode [90020-164])
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFacto
ry(BasicDataSource.java:1549)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:1044)
... 3 more
Caused by: org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked
by another process". Possible solutions: close all other connection(s); use the
server mode [90020-164]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.store.FileLock.getExceptionAlreadyInUse(FileLock.java:439)
at org.h2.store.FileLock.lockFile(FileLock.java:336)
at org.h2.store.FileLock.lock(FileLock.java:128)
at org.h2.engine.Database.open(Database.java:542)
at org.h2.engine.Database.openDatabase(Database.java:222)
at org.h2.engine.Database.<init>(Database.java:217)
at org.h2.engine.Engine.openSession(Engine.java:56)
at org.h2.engine.Engine.openSession(Engine.java:159)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:138)
at org.h2.engine.Engine.createSession(Engine.java:121)
at org.h2.engine.Engine.createSession(Engine.java:28)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.jav
a:305)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:72)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(Driv
erConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(Poolable
ConnectionFactory.java:582)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(Bas
icDataSource.java:1556)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFacto
ry(BasicDataSource.java:1545)
... 5 more
Aug 31, 2013 7:17:32 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Aug 31, 2013 7:17:32 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/BskDPP2013ExcelImportToDatabase-0.1] startup failed due to pre
vious errors
Aug 31, 2013 7:17:32 PM org.apache.catalina.loader.WebappClassLoader clearRefere
ncesJdbc
SEVERE: The web application [/BskDPP2013ExcelImportToDatabase-0.1] registered th
e JDBC driver [org.h2.Driver] but failed to unregister it when the web applicati
on was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unre
gistered.
The application, when run via run-app command(in intellij) works fine.
该应用程序在通过 run-app 命令(在 intellij 中)运行时工作正常。
Also if we see this line from the log:Cannot create PoolableConnectionFactory (Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-164])
,it says that the database is being used by some other process. However that can not happen because the database is HSQLDB which is internal with the grails application and no other external DBMS is being used.
此外,如果我们从日志中看到这一行:Cannot create PoolableConnectionFactory (Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-164])
,它表示该数据库正被其他进程使用。但是这不可能发生,因为数据库是 grails 应用程序内部的 HSQLDB,并且没有使用其他外部 DBMS。
I would surely upvote(and accept also if its the ultimate) any solution which solves(or atleast gives a direction to solve) the above issue.
我肯定会赞成(如果它是最终的,也接受)任何解决(或至少给出解决方向)上述问题的解决方案。
EDIT:Here is my DataSource.groovy
编辑:这是我的 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'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:file:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}
回答by dmahapatro
url = "jdbc:h2:file:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
refers to a H2 file
database. Can you try using in memory prodDb
instead if the intention was not to refer to a file database?
指的是 H2file
数据库。prodDb
如果不打算引用文件数据库,您可以尝试在内存中使用吗?
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
回答by rekinyz
because the "grails war" command generate war file using by default the productionenvironment that is defined in the DataSource.groovy. Maybe the production DB is no working yet, so you can try to run "grails test war" to build war with your Test DB.
因为“grails war”命令默认使用在DataSource.groovy 中定义的生产环境生成战争文件。也许生产数据库还没有工作,所以你可以尝试运行“grails test war”来与你的测试数据库建立战争。