6 Replies Latest reply on Jun 24, 2004 9:31 AM by jae

    Building EAR files

    annapurna Newbie

      Hi all,

      I am new to the concept of EAR. We have a EJB application with contains ejb-jars, utility jars and web.war files. Till now we deployed them individually in jboss deploy directory.Now we are asked to create one single ear to deploy these files.

      I understand that I have to write application.xml deployment descriptor file with ejb-jars and web.war details. Should I also mention utility jars in it. Also the same utility jars are used both by ejb-jars and by the web app. What is the most efficient way of deploying these utility jars.

      Any help is greatly appreciated.

      Thanks,
      Anna.

        • 1. Re: Building EAR files
          geoff74 Newbie

          To my understanding, utility jars can be referenced by including them in a Class-Path entry in the manifest file of a jar.

          There are a couple of articles here:
          http://www.onjava.com/pub/a/onjava/2001/06/26/ejb.html
          http://www.onjava.com/pub/a/onjava/2001/07/25/ejb.html

          Good luck!

          • 2. Re: Building EAR files
            jae Master

            you can also define all the utility jars in the application.xml file.

            ie:

             <module>
             <java>util.jar</java>
             </module>
            


            it's not portable (but why would you ever want to leave jboss), but it does work and i find it's easier then dealing w/ the manifest files.

            • 3. Re: Building EAR files - containing ejb and war, both using
              npaxton Newbie

              Along the lines of this thread, and having tried the suggestions, I still have the following problem:
              I have the need to have an EJB and a WAR in a single EAR. Originally, the jars are in the WAR (WEB-INF\lib). When I add the EJB, I need the ejb and the war to share those jars, originally in the web-inf\lib. They need not remain at the web-inf\lib directory. Preferably, we have a top-level directory "lib" that has all shared jars in it, or the jars sit at the top level of the ear.
              We are using maven to build the ejb/war/ear, and on JBoss 3.2.3.
              I have tried putting all the utility jars in a single "common.jar" and putting that in the manifest classpath. No luck.
              I have tried changing all the <war.bundle> tags to <ear.bundle>, hoping to put all the jars at the top level, making them available to both. No luck.
              I have tried using the <ejb.manifest.classpath> and <war.manifest.classpath> tags. No luck.
              Any suggestions?
              Thanks.

              • 4. Re: Building EAR files
                jae Master

                have you tried defining the jars in the application.xml file inside the ear?

                what you'll end up having is something like this (there are no jar files contained in the WEB-INF\lib directory of the war):


                my.ear
                + META-INF
                + application.xml
                + utility.jar
                + ejb.jar
                + webapp.war


                and your application.xml file will look like this:

                <?xml version="1.0" encoding="UTF-8"?>
                
                <application>
                 <display-name>My App</display-name>
                
                 <module>
                 <java>utility.jar</java>
                 </module>
                
                 <module>
                 <ejb>ejb.jar</ejb>
                 </module>
                
                 <module>
                 <web>
                 <web-uri>webapp.war</web-uri>
                 </web>
                 </module>
                </application>
                


                hopefully this will help get you past your problems.

                • 5. Re: Building EAR files
                  Ronaldo Nascimento Newbie

                  BTW, I think the classpath in MANIFEST way is cleaner.

                  Here's another question along the same thread. What if I a class within an ejb.jar within an ear and I want to access utility classes bundled into another ear. How would want configure that ?

                  Regards,

                  Roonaldo

                  • 6. Re: Building EAR files
                    jae Master

                    read this wiki page

                    http://www.jboss.org/wiki/Wiki.jsp?page=HotDeployClassCastExceptions

                    you are better off externalizing the utility classes bundled in the other ear into it's own standalone library that is deployed seperately.

                    the wiki page looks at it from the standpoint of doing hot deployments, but the overall idea is the same.