1

I was wondering if anyone had a luck deploying Grails 2.3.5 to Tomcat6

In BuildConfig I have grails.servlet.version = "2.5"

Plugins block looks like following:

plugins {
    build ":release:3.0.1"
    build ":tomcat:7.0.50"

    compile ":scaffolding:2.0.1"
    compile ':cache:1.1.1'

    runtime ":hibernate:3.6.10.7"
    runtime ":database-migration:1.3.8"
    runtime ":jquery:1.10.2.2"
    runtime ":resources:1.2.1"
}

On the startup I get following exception:

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

It starts up perfectly fine on Tomcat7. I have a suspicion that hibernate plugin is dragging hard dependency on Servlet 3, but that's just a guess at this stage.

Alidad
  • 5,463
  • 1
  • 24
  • 47
Kostya
  • 103
  • 1
  • 12
  • Does your generated .war include the file `WEB-INF/lib/grails-plugin-async-2.3.5.jar`? If so, try explicitly excluding that plugin. More details in a JIRA ticket that sounds similar: http://jira.grails.org/browse/GRAILS-9788 – Andrew Feb 11 '14 at 16:34
  • Also check `application.properties` for the proper `app.servlet.version`. – Andrew Feb 11 '14 at 18:07
  • I've added servlet version to application.properties - same result. – Kostya Feb 12 '14 at 01:22
  • I've removed the dependency on grails-pligin-async and it starts up fine, but only if I also remove dependency to org.grails.plugins:cache:1.1.1 and org.grails.plugins:hibernate:3.6.10.7, cause hibernate depends on async and doesn't startup if I exclude it and cache depends on hibernate... As a result I don't think combination of latest grails + tomcat6 + hibernate can actually work, unless anyone can suggest version of hibernate plugin that doesn't have this problem – Kostya Feb 12 '14 at 01:29
  • I'm a bit new to grails.... how did you remove the grails-async plugin? I'd thought this would work: `grails.project.dependency.resolution = { inherits("global") { excludes([group:'org.grails', name:'grails-async']) } ...` but the `WEB-INF/lib/grails-plugin-async-2.3.7.jar` is still present in the war file produced from a `grails war` command. – Brice Roncace Apr 16 '14 at 21:06
  • I was using maven to build the project. In BuildConfig I had "pom true" and set all dependencies in pom.xml. However as I mentioned earlier you cannot use hibernate with this combination because of dependency chain it has. In the end of the day we managed to just upgrade to tomcat7. – Kostya Apr 17 '14 at 05:20

1 Answers1

1

For me upgrading to latest minor version solve this issue.

  • Make sure you upgrade to the latest version of the Grails 2.3.x (currently 2.3.11). It is as easy as changing the value in the application.properties
  • In your BuildConfig.groovy make sure to set grails.servlet.version = "2.5"

After these changes the Grails up could be deployed into Tomcat 6.0.x container.

Hope it helps Eduardo

ECostello
  • 169
  • 1
  • 17