marius
marius

Reputation: 61

Grails deployment on Tomcat

I am trying to deploy a Grails app using Tomcat 6.0. When I use the db packaged with Grails it works fine. However, when I use PostgreSQL I get a status 404 error.

The log give me the following:

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 

Any advice would be greatly appreciated.

As requested here is the 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"
        }
    }
 }

Here is the buildconfig file:

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'
    }
}

After making changes to the datasource and config files as suggested by Oliver I get the following result: I do not get the 404 error anymore, but Tomcat now hangs and do not display the website. The error log gives me the following error:

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'

Upvotes: 0

Views: 1221

Answers (1)

Oliver Tynes
Oliver Tynes

Reputation: 964

You dont have the drivers installed.

dependencies {
    runtime 'postgresql:postgresql:9.0-801.jdbc4'
}

Change your buildconfig to that and it should load.

Also the jdbc url should look something like:

jdbc:postgresql://localhost:5432/grails

Obviously replace port and database name with whatever you have set up in postgresql.


Edit based on further information:

Increase your permgen, either with a run-config or with exporting to GRAILS_OPTS. You do this differently according to what IDE you use, so google is your friend from here on. If you can't figure out that on your own, it would be a separate question anyhow, so feel free to accept this one as answered :-)

Upvotes: 2

Related Questions