4 Replies Latest reply on Feb 13, 2012 3:26 PM by Andreas Hess

    Deployment of simple JAR in EAR

    Andreas Hess Newbie

      @All

       

      For the last couple of days I tried to find a solution to the following problem:

       

      I'm porting a JBoss AS5.1 application to JBoss AS 7.1. The structure of the EAR is pretty simple:

       

      MY.EAR

      |--META-INF/lib/<all needed external jar files>

      |-- EJB1.JAR

      |-- EJB2.JAR

      |--MYJAR.JAR (has the  @local interfaces and other helper classes)

      |--WEB.WAR

       

      I have added the MYJAR.JAR to the MANIFEST.MF Class-Path: in both EJB-JAR files and the application starts without any issues.

      But as soon as I try to start something (first time an EJB instance is created) it fails with a ClassNotFoundException. Looks like the classes in MYJAR.JAR can't find the classes from within any of the external JAR files from the EAR/lib directory.

       

      I have read ALL about the new module class loaders, but whatever I have tried it did not help.

       

      I've also tried to make the MYJAR.JAR a EJB-JAR. This helped and fixed the class loading problems, but is only a workaround.

       

      My question:

       

      Is this a bug? It used to work without any issues in AS5.1.

       

      Or

       

      How can I define the dependency from the deployment.MY.EAR.MYJAR.JAR to have access to EAR/lib?

       

      Any help is welcome.

        • 1. Re: Deployment of simple JAR in EAR
          jaikiran pai Master

          If your myjar.jar contains just the bean interfaces then it should be placed in the .ear/lib folder along with the other libraries.

           

          P.S: I guess the packaging structure you posted has a typo - the lib folder should be at the root of the .ear and not in the META-INF of the .ear

          • 2. Re: Deployment of simple JAR in EAR
            Andreas Hess Newbie

            Hi

             

            1. You are right! The lib directory is in the root of the EAR and NOT in META-INF.

             

            2. The myjar.jar has more than just the bean interfaces. The position inside the EAR is not in question as this is a development policy from the project owner. It also works fine this way for AS5 or AS6.

             

            The "AS7 class loading" description says something like: "The EAR/lib is one module; each EJB-JAR and WAR is a separate module with assess to the EAR/lib".

            The myjar.jar library in the root of the EAR is also a module in the class loader (deployment.myear.ear.myjar.jar), but is has no access to the EAR/lib module.

             

            How can I define this dependency ?

            • 3. Re: Deployment of simple JAR in EAR
              jaikiran pai Master

              Andreas Hess wrote:

               

               

              2. The myjar.jar has more than just the bean interfaces.

              What other things does it contain? Any components like EJBs?

               

               

              Andreas Hess wrote:

               

              The myjar.jar library in the root of the EAR is also a module in the class loader (deployment.myear.ear.myjar.jar), but is has no access to the EAR/lib module.

               

              If that myjar.jar doesn't contain any components then it will not be treated as a subdeployment. The EE spec says that plain library jar files should be packaged in the library directory which by default is .ear/lib folder.

              1 of 1 people found this helpful
              • 4. Re: Deployment of simple JAR in EAR
                Andreas Hess Newbie

                jaikiran pai schrieb:

                 

                What other things does it contain? Any components like EJBs?

                 

                 

                It contains normal JAVA classes (POJO). No J2EE!

                 

                 

                jaikiran pai schrieb:

                 

                 

                If that myjar.jar doesn't contain any components then it will not be treated as a subdeployment. The EE spec says that plain library jar files should be packaged in the library directory which by default is .ear/lib folder.

                 

                Here is the answer. No J2EE! It looks like a subdeployment, but it has no access to ear/lib. I converted the JAR into an EJB-JAR.

                 

                It only confused me that AS5/AS6 did a full EJB-JAR like deployment on a simple JAR.

                 

                Workaround is in place. Problem solved. Thanks!