Deplyoing a Grails application to JBoss

So it seems that every month or so I am able to blow the dust off my little Groovy on Grails project and progress it a little. A little frustrating, since the elapsed time of this belies the gains in using grails.

I have a working application. It has a few rough edges, but for all intents and purposes, it’s there. I just needed to see if creating war and deploying to the target environment, JBoss.

Surely it can’t be as simple as…

C:\local\groovy\my_app> grails war

No, it isn’t… But nearly!

Deploying into JBoss, the problem I hit was down to log4j and the jar within the deployed grails application conflicting with the one in JBoss.

Obviously this has all been covered before and a few alternatives are offered on the grails faq.

Q: I’m getting errors when deploying on JBoss 4.0.x What do I do?

First off I had to scope the application classloader. To do this for a war, create a file called jboss-web.xml with content like the following:

<jboss-web> 
  <class-loading java2ClassLoadingCompliance = "false"> 
    <loader-repository> my_app:loader=my_app-0.1.war 
      <loader-repository-config>java2ParentDelegation=false</loader-repository-config> 
    </loader-repository> 
  </class-loading> 
</jboss-web>

and place it in the web-app\WEB-INF folder.

This still isn’t quite enough to get it to work though, since the log4j.properties file used by JBoss still results in a conflict of interest.

Luckily enough I was able to take the preferred solution of renaming JBoss’ log4j.xml to jboss-log4j.xml and editing the jboss-service.xml file such that the ConfigurationURL of org.jboss.logging.Log4JServicepoints to the renamed file.

Et voila!

comments powered by Disqus