Grails部署问题(WAR和Tomcat)

我正在努力在远程服务器上的Tomcat 6下部署WAR。现在,如果我将其部署在本地计算机上,则一切正常。远程部署会触发一组非常不友好的异常。

log4j:ERROR setFile(null,true) call failed.

java.io.FileNotFoundException: stacktrace.log (Permission denied)

at java.io.FileOutputStream.openAppend(Native Method)

at java.io.FileOutputStream.<init>(FileOutputStream.java:207)

at java.io.FileOutputStream.<init>(FileOutputStream.java:131)

at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)

at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:616)

<...snip>

ERROR initWebApplicationContext, Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': 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.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (File input/output error prodDB.properties java.io.FileNotFoundException: prodDB.properties.new (Permission denied))

at java.lang.Thread.run(Thread.java:636)

Caused by: 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.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (File input/output error prodDB.properties java.io.FileNotFoundException: prodDB.properties.new (Permission denied))

... 1 more

Caused by: 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.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (File input/output error prodDB.properties java.io.FileNotFoundException: prodDB.properties.new (Permission denied))

... 1 more

Caused by: 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.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (File input/output error prodDB.properties java.io.FileNotFoundException: prodDB.properties.new (Permission denied))

... 1 more

Caused by: 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 PoolableConnectionFactory (File input/output error prodDB.properties java.io.FileNotFoundException: prodDB.properties.new (Permission denied))

... 1 more

Caused by: org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (File input/output error prodDB.properties java.io.FileNotFoundException: prodDB.properties.new (Permission denied))

... 1 more

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (File input/output error prodDB.properties java.io.FileNotFoundException: prodDB.properties.new (Permission denied))

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)

at $Proxy15.getMetaData(Unknown Source)

... 1 more

Caused by: java.sql.SQLException: File input/output error prodDB.properties java.io.FileNotFoundException: prodDB.properties.new (Permission denied)

at org.hsqldb.jdbc.Util.sqlException(Unknown Source)

at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)

at org.hsqldb.jdbcDriver.getConnection(Unknown Source)

at org.hsqldb.jdbcDriver.connect(Unknown Source)

at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)

at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)

... 3 more

我正在使用HSQLDB作为数据库。

Tomcat是作为服务运行的,因此 不应

有任何权限问题。我是否需要更改某些权限(如果是,在哪里更改,因为我找不到尝试的访问权限)?我可以在Grails中设置一个配置选项以不记录日志或重定向记录日志吗?

回答:

这与记录无关,而与“

prodDB.properties”有关。您正在获取FileNotFoundException,因为它无法编写(或可能重命名)它。运行该应用程序的用户不得在创建HSQLDB数据库文件的目录中具有写权限。

默认配置使用相对路径,因此它将在应用程序从以下位置启动时进行编写:

production {

dataSource {

dbCreate = "update"

url = "jdbc:hsqldb:file:prodDb;shutdown=true"

}

}

一种解决方法是在DataSource.groovy中对路径进行硬编码:

production {

dataSource {

dbCreate = "update"

url = "jdbc:hsqldb:file:/some/writeable/folder/prodDb;shutdown=true"

}

}

更好的方法是在Config.groovy中启用外部配置文件:

grails.config.locations = ["classpath:${appName}-config.groovy"]

并创建foo-config.groovy包含

dataSource {

url = "jdbc:hsqldb:file:/some/writeable/folder/prodDb;shutdown=true"

}

并将foo-config.groovy放在Tomcat的类路径中的$ TOMCAT_HOME /

lib中(将foo更改为您的应用程序名称)。这样,您可以将战争部署到多个位置,并且仅覆盖配置文件,而不用硬编码Config.groovy中的单个值。

以上是 Grails部署问题(WAR和Tomcat) 的全部内容, 来源链接: utcz.com/qa/420217.html

回到顶部