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:
- Change the XML schema declaration in the generated web.xml file to use Servlet specification 2.4 rather than 2.5
- 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:
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(WebAppModule.java:781)
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:272)
at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:360)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:56)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:46)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:147)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.createAndPrepareContainer(RedeployOperation.java:98)
at weblogic.deploy.internal.targetserver.operations.RedeployOperation.doPrepare(RedeployOperation.java:118)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:718)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1185)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:247)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:157)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: com.bea.xml.XmlException: failed to load java type corresponding to e=web-app@http://java.sun.com/xml/ns/javaee
at com.bea.staxb.runtime.internal.UnmarshalResult.getPojoBindingType(UnmarshalResult.java:325)
at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:292) 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:
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:
weblogic.application.ModuleException: at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:891) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:333) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60) Truncated. see log file for complete stacktrace java.lang.InternalError: erroneous handlers at org.hibernate.validator.xml.ValidationXmlParser.parseValidationXml(ValidationXmlParser.java:60) at org.hibernate.validator.engine.ConfigurationImpl.parseValidationXml(ConfigurationImpl.java:252) at org.hibernate.validator.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:143) at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111) at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:380) Truncated. see log file for complete stacktrace
This one is actually quite easy to fix. Just download JAXB from https://jaxb.java.net, 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',
'com.sun.xml.bind:jaxb-xjc:2.1.12',
'com.sun.xml.bind:jaxb1-impl:2.0.3'
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.