Home     Profile     Services     Expertise     Software

JBoss Patch


Introduction

During J2EE development I don't want to go through lengthy packaging and deployment cycles. Sure, to get around that, I can run my application in an expanded ear directory. But what if I also want to develop my application in two different Application Servers, or two different versions of JBoss? Or I want to port an existing development effort into JBoss, without rebuilding my IDE project settings and ant build files. If my application is already structured as an exploded EAR file, I could just add the parent directory as an additonal URL to the main deployer. But things aren't always a neat EAR file. Sometimes its a WAR file here, and an EJB-Jar there... JBoss does support exploded EAR files, but the EAR contents must be within the EAR directory itself. I suppose on Unix the contents of the EAR file could be linked into the EAR directory, but on Windows its a little bit more difficult.


Description

I've patched the JBoss EAR deployer to enable EAR modules (WARs and EJB Jars), to live outside of the JBoss EAR directory. Instead of defining your moudles in an application.xml file, define them in the JBoss specific jboss-app.xml file and use the external-path element. Note that the directories must still be named appropriately to be recognized by the WAR and JAR deployers.


Notes

  1. I have not tested this patch with SARs (JBoss Service Archive) but they should also work with the external-path element.

  2. Is is possilbe to add additonal URLs to the main class-path in jboss-service.xml if your compiled classes are not where they should be according to the J2EE spec (not in WEB-INF\classes or under the EJB-JAR directory).

  3. The changes in this patch are minimal (as seen through a compare), and I suspect it should be easy to make the same changes to other versions of JBoss besides 3.2.2.


Configuration Instructions

Assume the following directory structures:


J2EE Application Layout:


JBoss Layout:


To configure the application residing under C:\myApp in JBoss the files under
C:\jboss-3.2.2\server\default\deploy\myApp.ear\META-INF would look like the following:


application.xml:

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.
    //DTD J2EE Application 1.2//EN' 'http://java.sun.com/j2ee/dtds/application_1_2.dtd'>
  
  <application>
    <display-name>myApp</display-name>
    <!-- All the module are defined in jboss-app.xml -->
  </application>


jboss-app.xml:

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.
    //DTD J2EE Application 1.2//EN' 'http://java.sun.com/j2ee/dtds/application_1_2.dtd'>
  
  <jboss-app>
     <module>
       <ejb>ejbstuff.jar</ejb>
       <external-path>C:\myApp\ejbstuff.jar</external-path>
     </module>
     <module>
       <web>
         <web-uri>webstuff.war</web-uri>
         <context-root>webstuff</context-root>
       </web>
       <external-path>C:\myApp\webstuff.war</external-path>
    </module>
  </jboss-app>


Patch Instructions

  1. Download and unpack the JBoss 3.2.2 source
  2. Replace %SRC%/server/src/main/org/jboss/deployment/EARDeployer.java
    and
    %SRC%/server/src/main/org/jboss/deployment/J2eeModuleMetaData.java
    with the copies included with this patch. (I know these should be .diff files)
  3. Build JBoss using %SRC%/build/build.bat


Downloads

jboss-4.0.2-patch.zip

jboss-3.2.7-patch.zip

jboss-3.2.6-patch.zip

jboss-3.2.5-patch.zip

jboss-3.2.3-patch.zip

jboss-3.2.2-patch.zip

jboss-3.0.8-patch.zip


Feedback

If you have any suggestions or bug report send them to: andre@askitservices.com