Tuesday, 2 February 2010

Building your own jbossall-client.jar

The newer versions of JBoss (I'm using 5.1.0 GA) very annoyingly have all the client jars split into at least 47 separate jars! Which is a bit rude when you consider the total number of jars they expect you to copy into your tomcat/lib dir is a whopping 93.

JBoss are declined to make the client jars into a single file again as its meant to make it easier to upgrade... That's arguable but still leaves us with all these files to copy around. After searching the net I've found a rather nice solution which I have adapted below.
The way I use it is as follows. I combine all jboss*.jar files into a single jar and then copy the additional dependencies.

Create a directory an empty directory and put the build.xml in it and create a /jboss dir. Copy all jboss jboss*.jar from jboss-5.1.0.GA/client.

Create a /build.xml:
<project default="combine">
   <property name="temp.dir" value="unpacked" />
   <property name="lib.dir" value="jboss" />
   <property name="jar.filename" value="jbossall-client.jar" />

   <target name="clean">
      <delete dir="${temp.dir}" quiet="true" />
      <delete file="${base.dir}/${jar.filename}" quiet="true" />
   </target>
   
   <target name="unjar.jar">
      <unjar dest="${temp.dir}">
         <patternset>
            <exclude name="META-INF/MANIFEST.MF" />
         </patternset>
         <fileset dir="${lib.dir}">
            <include name="**/*.jar" />
         </fileset>
      </unjar>
   </target>


   <target name="combine" depends="unjar.jar">
      <jar jarfile="${basedir}/${jar.filename}"
         basedir="${temp.dir}" update="true"
         compress="false">
      </jar>
   </target>
</project>
It will extract and recombine the jar files for you.

The dependencies I also copy across are:
concurrent.jar
ejb3-persistence.jar
hibernate-annotations.jar
javassist.jar
jmx-client.jar
jmx-invoker-adaptor-client.jar
jnp-client.jar
trove.jar
xmlsec.jar

3 comments:

  1. I have all 93 in my tomcat lib - do you absolutely need all 93?

    I'm having problems with the jbossws-* jars causing a tomcat jax-ws web service to err on deployment (SaajFactory issues). When I remove these jbossws-* jars from the tomcat/lib folder it works fine?

    ReplyDelete
  2. You can run a cut down list - depending on what you use. I didn't include any webservices jars as I was not using jboss webservices client.

    I used trial and error to include the bare minimum. Although you might get a few unexpected errors if your missing one.

    ReplyDelete
  3. I opened topic in jboss forum,
    http://community.jboss.org/thread/167201
    one big problem for lookup ejb3.1 bean from client appl, need jboss client jars, in the JBoss 4 we used only jbossall-client.jar, now I do not know for JBOSS 6 which jars I must use? Help.

    ReplyDelete