Deploying Grails 3.1 Applications to JBoss 6.4 EAP
May 26, 2016
We had previously described how to deploy Grails 3.1 applications to WildFly 10, which is where all of the "cutting edge" work happens in the JBoss world.
The process to deploy Grails 3.1 applications to JBoss 6.4 EAP is largely similar, with some minor configuration differences.
Firstly, you have to configure your dependencies in
build.gradle correctly by marking Tomcat as a provided dependency and including JAXB as a runtime dependency:
provided "org.springframework.boot:spring-boot-starter-tomcat" runtime 'javax.xml.bind:jaxb-api:2.2.12'
Next you need to create a
src/main/webapp/WEB-INF/jboss-deployment-structure.xml file with the following contents:
<?xml version='1.0' encoding='UTF-8'?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1"> <deployment> <exclusions> <module name="javaee.api"></module> <module name="javax.validation.api"></module> <module name="javax.faces.api"></module> <module name="org.hibernate.validator"></module> </exclusions> </deployment> </jboss-deployment-structure>
This will prevent JBoss from loading any APIs that conflict. For example Grails ships with
javax.validation version 1.1 but JBoss 6.4 comes prepackages with version 1.0, so without this configuration you would end up with an exception such as:
Caused by: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider; at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:119) at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:45)
With these two changes in place you can run
gradle assemble to produce a WAR file that can be deployed to JBoss 6.4 EAP!