我正在尝试使用Tomcat 6.0部署Grails应用。当我使用与Grails打包的数据库时它工作正常。但是,当我使用PostgreSQL时,我收到状态404错误。
日志给我以下内容:
Nov 12, 2011 7:44:40 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\TortoiseSVN\bin;;.
Nov 12, 2011 7:44:41 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Nov 12, 2011 7:44:41 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2901 ms
Nov 12, 2011 7:44:42 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Nov 12, 2011 7:44:42 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.33
Nov 12, 2011 7:44:42 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
Nov 12, 2011 7:44:42 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive HighPoint-0.1.war
Nov 12, 2011 7:44:43 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Nov 12, 2011 7:44:43 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/HighPoint-0.1] startup failed due to previous errors
Nov 12, 2011 7:44:43 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive Test-0.1.war
Nov 12, 2011 7:45:00 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive Test2-0.1.war
Nov 12, 2011 7:45:20 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Nov 12, 2011 7:45:20 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Nov 12, 2011 7:45:21 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Nov 12, 2011 7:45:21 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Nov 12, 2011 7:45:21 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/63 config=null
Nov 12, 2011 7:45:21 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 39476 ms
非常感谢任何建议。
这里要求的是datasource.config:
dataSource {
pooled = true
driverClassName = "org.postgresql.Driver"
}
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:postgresql:Test"
username = "postgres"
password = "highpoint"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:postgresql:Test"
username = "postgres"
password = "highpoint"
}
}
production {
dataSource {
dbCreate = "create-drop"
url = "jdbc:postgresql:Test"
username = "postgres"
password = "highpoint"
}
}
}
这是buildconfig文件:
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//mavenLocal()
//mavenCentral()
//mavenRepo "http://snapshots.repository.codehaus.org"
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.13'
}
}
按照Oliver的建议更改数据源和配置文件后,得到以下结果: 我不再得到404错误,但Tomcat现在挂起并且不显示网站。错误日志给出了以下错误:
Nov 18, 2011 1:03:01 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Nov 18, 2011 1:03:02 PM org.apache.tomcat.util.digester.Digester endElement
SEVERE: End event threw error
java.lang.OutOfMemoryError: PermGen space
Nov 18, 2011 1:03:02 PM org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory docs
java.lang.OutOfMemoryError: PermGen space'
答案 0 :(得分:2)
您没有安装驱动程序。
dependencies {
runtime 'postgresql:postgresql:9.0-801.jdbc4'
}
将buildconfig更改为,并且应该加载。
此外,jdbc网址应如下所示:
jdbc:postgresql://localhost:5432/grails
显然用你在postgresql中设置的内容替换端口和数据库名称。
根据更多信息进行编辑:
使用run-config或导出到GRAILS_OPTS来增加permgen。你根据你使用的IDE来做不同的事情,所以谷歌是你的朋友。如果你无法自己解决这个问题,那么无论如何都会是一个单独的问题,所以请随意接受这个问题作为回答:-)