The Bad Programmer

Grails: Deploy Grails 2.x or newer application to Weblogic 9

If you try to deploy a Grails application built with Grails 2.0 or greater to Weblogic 9.0 it will fail. There are two things you need to do to get a Grails 2.0 application to deploy to Weblogic 9. These occur because of Weblogic 9’s use of Java 1.5.

As an overview the 2 things you need to do are:

  1. Change the XML schema declaration in the generated web.xml file to use Servlet specification 2.4 rather than 2.5
  2. Put the JAXB jars in the lib folder of the project

Change XML schema declaration of web.xml

Starting with Grails 2.0 the XML Schema declaration in web.xml is for Servlet spec 2.5:

<web-app version=”2.5″  metadata-complete=”true” xmlns=”” xmlns:xsi=”” xsi:schemaLocation=””>

Your app will not deploy to Weblogic 9 with this declaration in your web.xml. You will get an exception that looks like this:

[HTTP:101064][WebAppModule(ivrtester:ivrtester.war)] Error parsing descriptor in Web appplication weblogic.application.ModuleException: Unmarshaller failed 
at weblogic.servlet.internal.WebAppModule.loadDescriptor( 
at weblogic.servlet.internal.WebAppModule.prepare( 
at weblogic.application.internal.flow.ScopedModuleDriver.prepare( 
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare( 
at weblogic.application.internal.flow.DeploymentCallbackFlow$ 
at weblogic.application.utils.StateMachineDriver.nextState( 
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare( 
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare( 
at weblogic.application.internal.BaseDeployment$ 
at weblogic.application.utils.StateMachineDriver.nextState( 
at weblogic.application.internal.BaseDeployment.prepare( 
at weblogic.application.internal.DeploymentStateChecker.prepare( 
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare( 
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.createAndPrepareContainer( 
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.doPrepare( 
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare( 
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare( 
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList( 
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare( 
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare( 
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback( 
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000( 
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$ 
at at 
Caused by: com.bea.xml.XmlException: failed to load java type corresponding to e=web-app@ 
    at com.bea.staxb.runtime.internal.UnmarshalResult.getPojoBindingType( 
    at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement( at

To fix this the declaration needs to be changed to a Servlet spec 2.4 declaration. However, by default you can’t see the web.xml that Grails packages into the war file. This web.xml file is included in the templates, so to get it execute:

grails install-templates

This will put the templates under the src/ directory. The web.xm file is found at src/templates/war/web.xml edit web.xml and change the opening web-app tag to:

<web-app xmlns=”” xmlns:xsi=”” xsi:schemaLocation=”” version=”2.4″>

When you do a grails war this web.xml will be used and this fixes the first deployment problem.

Put JAXB in the lib/ directory

The next problem is that Weblogic 9 requires Java 1.5 which does not include JAXB which wasn’t included in the JDK until Java 1.6 (in Update 3 if I recall correctly). Starting with Grails 2.0 JAXB appears to now be a required dependency (or it always was but Grails just stopped including it with Grails since it is included in Java 1.6 now).

If you do not include JAXB in lib/ you will get an exception that looks like this:

at weblogic.servlet.internal.WebAppModule.startContexts(
at weblogic.servlet.internal.WebAppModule.start(
at weblogic.application.internal.flow.ModuleStateDriver$
at weblogic.application.utils.StateMachineDriver.nextState(
at weblogic.application.internal.flow.ModuleStateDriver.start(
Truncated. see log file for complete stacktrace
java.lang.InternalError: erroneous handlers
at org.hibernate.validator.xml.ValidationXmlParser.parseValidationXml(
at org.hibernate.validator.engine.ConfigurationImpl.parseValidationXml(
at org.hibernate.validator.engine.ConfigurationImpl.buildValidatorFactory(
at javax.validation.Validation.buildDefaultValidatorFactory(
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(
Truncated. see log file for complete stacktrace

This one is actually quite easy to fix. Just download JAXB from, unzip it and copy jaxb-api.jar, jaxb-impl.jar, jaxb-xjc.jar, and jaxb1-impl.jar to the lib/ directory in your project. Any jars in the lib/ directory automatically get added to WEB-INF/lib in the generated war file.

You could alternatively try to get JAXB from IVY. For some reason I remember having issues with this working. However, I can’t recall the exact problem I had right now. So you can try adding this to Build.config in the dependencies closure. You should of course change the version numbers to the one you want.

runtime 'com.sun.xml.bind:jaxb-impl:2.1.12',

You only need to do one or the other. Either put the jars directory in lib/ or try using IVY.

This should fix the final problem with getting a Grails 2.x app to deploy to Weblogic. I have used this to deploy a Grails 2.0.1 and Grails 2.2 application to Weblogic 9.