Reputation: 459
I'm trying to deploy a Grails application to a Tomcat container, running on Ubuntu. I was trying to do "everything right", but still can't get it to work. Any ideas?
I'm running "Ubuntu Server 12.04.3 LTS". I installed the Tomcat that is bundled with Ubuntu (6.0.35). I know Grails can use a lot of memory, so I raised the memory allocated to the JVM to 512MB. The example applications supplied with Tomcat work fine.
On my PC (running Windows 7) I installed Grails (latest version: 2.3.7) and NetBeans (version: 7.4).
I created a very simple "Hello world" Grails application. I have some trouble running it on my PC (another question I just posted), but it compiles just fine and I can create a War-file without problems. By running "grails war".
I've used the Tomcat "Web Application Manager" to upload the War-file. It is put in /var/lib/tomcat6/webapps as it should, unpacked and everything looks fine.
But when I try to start the application (choosing "Start" in the manager), I get a "FAIL - Application at context path /MyTestApp could not be started" message. I've tried to restart Tomcat, but get the same problem.
When I look at the Tomcat log (catalina.out), this is logged:
2014-03-14 20:24:32,148 [http-8080-1] ERROR context.ContextLoader - Context
initialization failed
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'grailsApplication' defined in ServletContext
resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed;
nested exception is java.lang.NoClassDefFoundError: javax/servlet/AsyncContext
at java.lang.Thread.run(Thread.java:701) Caused by:
java.lang.NoClassDefFoundError: javax/servlet/AsyncContext
at java.lang.Class.privateGetDeclaredMethods(Class.java:2534)
at java.lang.Class.getDeclaredMethods(Class.java:1855)
...
Caused by: java.lang.ClassNotFoundException: javax.servlet.AsyncContext
It seems like the "javax.servlet.AsyncContext" class couldn't be found. The Grails documentation says that running Grails on Tomcat is a piece of cake, and that nothing should go wrong... The "javax.servlet.AsyncContext" class seems to have something to do with "Servlet 3.0", but I don't know much about Java EE. I just thought latest-version-of-everything would work out of the box...
Is there anything I need to install on the server? Anything to add to Tomcat? Or some configuration I should change in my application?
I'd be very grateful for any help! :-)
/Anders from Sweden
Upvotes: 3
Views: 3423
Reputation: 50245
It is a piece of cake if an appropriate version of Tomcat with this version of Grails is used. :)
Latest version of Grails uses Servlet 3.0 and embedded Tomcat 7.0.52.1 (used during run-app) by default and I doubt it will be compatible with Tomcat 6.0.35. But you can downgrade the servlet version to 2.5 or 2.4 according to your need as:
//BuildConfig.groovy (first line)
grails.servlet.version = "3.0" //2.4 or 2.5
Upvotes: 5