4 Replies Latest reply on Apr 23, 2013 2:23 AM by Thorben Janssen

    JBOSS 7.1.1 Ear with External Jar dependency

    Kevin Stone Newbie

      I am currently transitioning from Jboss 5 to 7.  Our application has multiple jars which use a utilities jar.  I can make my stuff work if I include the utilities jar in my ear, include appplication.xml in the ear META-INF, and include jboss-deployment-structure.xml and MANIFEST.MF in the jar META-INF.  Has anyone found another way to make the utilities jar available to the ear?  Don't point me to the documentation, I've tried just about every variation of creating a module and trying to get my ear to use it.

        • 1. Re: JBOSS 7.1.1 Ear with External Jar dependency
          rsearls Newbie

          Defning a module would be the way to go.

          What issue did you encounter in creating a module for it?

          • 2. Re: JBOSS 7.1.1 Ear with External Jar dependency
            jaikiran pai Master

            Kevin Stone wrote:

             

            Our application has multiple jars which use a utilities jar.  I can make my stuff work if I include the utilities jar in my ear, include appplication.xml in the ear META-INF, and include jboss-deployment-structure.xml and MANIFEST.MF in the jar META-INF. 

            The Java EE spec specified portable way of doing it is packaging that utility jar within the .ear/lib folder (create the lib folder if it isn't there). You don't see any of JBoss specific deployment descriptors for that to work.

            • 3. Re: JBOSS 7.1.1 Ear with External Jar dependency
              Kevin Stone Newbie

              The problem I had with a module was that JBOSS 7.1.1 seemed to hang when my jar tried to invoke a method in the other jar.  Here is what I did.

               

              First, I created the folder $JBOSS_HOME/modules/mymod/jar/main

              I put the myutils.jar file into that folder.

              I created the the module.xml file in the folder:

                  <module xmlns="urn:jboss:module:1.0" name="mymod.myutils.jar">
                      <dependencies>
                          <module name="javax.jms.api"/>
                          <module name="javax.jws.api"/>
                          <module name="javax.xml.bind.api"/>
                          <module name="javax.xml.ws.api"/>
                          <module name="org.apache.commons.cli"/>
                          <module name="org.apache.commons.pool"/>
                          <module name="org.apache.log4j"/>
                          <module name="org.junit"/>
                      </dependencies>
                   <resources>
                        <resource-root path="myutils.jar"/>
                   </resources>
              </module>

               

              In the myutils.jar there is a class called QueueUtils and it has a method sendMessage that sends a message to a hornet queue.

               

              Second I created my jar, myapp.jar.  In it I have a method that calls the sendMessage method in QueueUtils.

              I also included a jboss-deployment-structure.xml in the META-INF folder of myapp.jar.  It has myutils.jar as a dependency:

               

              <?xml version="1.0"?>
              <jboss-deployment-structure>
                <deployment>
                   <dependencies>
                      <module name="javax.ejb.api"/>
                      <module name="javax.inject.api"/>
                      <module name="javax.jms.api"/>
                      <module name="javax.jws.api"/>
                      <module name="javax.persistence.api"/>
                      <module name="javax.transaction.api"/>
                      <module name="javax.xml.bind.api"/>
                      <module name="javax.xml.ws.api"/>
                      <module name="org.apache.commons.cli"/>
                      <module name="org.apache.log4j"/>
                      <module name="org.jboss.ejb3"/>
                      <module name="mymod.myutils.jar"/>

                   </dependencies>
                </deployment>
              </jboss-deployment-structure>

               

              Third I deployed myapp.jar.  It deployed OK and I could see in the debug that it loaded the myutils.jar as a dependency.

               

              Finally, I ran a test where a class in myapp.jar calls the QueueUtils sendMessage method.  I have log.info message as the very first line in QueueUtils.sendMessage.

              When the call is made, it never completes, no error, nothing.  I don't see the log.info in the server log.

               

              As far a using a lib in an ear, I really can't create myapp.ear abd put myutils.jar in a lib foder because we have many other jars that use the myutils.jar.

              I can't imagine everytime a change is made to myutils having to redeploy 10 ears on 20+ servers.

               

              Thanks for any help you can provide

               

              Oh, and also:  When I put QueueUtils into myapp.jar the call works.

               

              1 of 1 people found this helpful
              • 4. Re: JBOSS 7.1.1 Ear with External Jar dependency
                Thorben Janssen Newbie

                The name of your module in module.xml has to match the path. So it has to be $JBOSS_HOME/modules/mymod/myutils/jar/main