繁体   English   中英

Grails部署问题(WAR和Tomcat)

[英]Grails deployment issues (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中对单个值进行硬编码。

当我升级到Windows 7时,我突然遇到了这个问题。我一直在使用快捷方式启动Tomcat,并将“Start In”目录设置为普通的“C:\\”。 Windows 7不允许非管理员用户写入此目录。 我创建了一个名为“TomcatData”的用户主目录的子目录,并改变了我的快捷方式,从那里启动Tomcat。 现在一切都很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM