2 Replies Latest reply on Aug 29, 2012 11:12 AM by markorocko

    How to make libs.jar accessible to both EJBs and WebApp?

    markorocko

      Anyone know how to resolve this?  FYI- Running AS7

      I have

      EAR----------

           app.war

           libs.jar

           ejb1.jar

           ejb2.jar

      EAR----------

       

       

      Now inside my app.war

      WAR---------

           WEB-INF

                classes

                lib

      WAR---------

       

      Problem- classes inside the app.war cannot see my libs.jar.

      Poor workaround - An easy way to fix this is to just redundantly add libs.jar to the lib directory but then it's redundantly in two places(EAR and WAR).

       

      Is there a more elegant way to permit the class files inside the war to see the libs.jar?

        • 1. Re: How to make libs.jar accessible to both EJBs and WebApp?
          swd847

          Place libs.jar in EAR/lib, and then it will be visible to all your wars and EJB jars (this is part of the EE6 standard).

          • 2. Re: How to make libs.jar accessible to both EJBs and WebApp?
            markorocko

            Yes, thanks!

             

            How to Package EARs and WARs

            When you migrate your application, you may have to change the packaging structure of your EAR or WAR due to the class loading changes.

            A WAR is a single module and all classes in the WAR are loaded with the same class loader. This means classes packaged in the WEB-INF/lib are treated the same as classes in WEB-INF/classes.

            An EAR is different in that it consists of multiple modules. The EAR/lib directory is a single module, and every WAR or EJB jar deployment is also a separate module. Classes will not necessarily have access to other classes in the EAR unless explicit dependencies have been defined.

            For more information on EAR and WAR packaging, see "WAR Class Loading" and "EAR Class Loading" in Class Loading in AS7.