13 Replies Latest reply on Apr 18, 2007 5:11 PM by Elias Ross

    Where do external jar files go in the ear?

    Graeme Harnish Newbie

      Where do you place external jar files in the ear file to use?

      I've tried:
      lib/
      META-INF/lib
      APP-INF
      APP-INF/lib
      .

      Everytime I get a ClassNotFoundException, Any ideas?

      Thanks.

        • 1. Re: Where do external jar files go in the ear?
          Laszlo Borsos Newbie

          AFAIK there is no automatic inclusion of jar files in an EAR. You can define them in application.web:

          <module>
           <java>myjar.jar</java>
          </module>
          

          And you place it in the root dir. of the EAR.

          • 2. Re: Where do external jar files go in the ear?
            Laszlo Borsos Newbie

            Sorry, application.xml

            • 3. Re: Where do external jar files go in the ear?
              Weston M. Price Master

               


              AFAIK there is no automatic inclusion of jar files in an EAR. You can define them in application.web:
              Code:

              <module>
              <java>myjar.jar</java>
              </module>


              And you place it in the root dir. of the EAR.



              Not a good idea. The element is to be used for J2EE application clients and should not be used as a method for deploying third party/utility jars.

              The correct way to do this is to define a Classpath entry in the MANIFEST.MF file of each J2EE module (ie EJB jar file/WAR file).

              Example MANIFEST.MF

              
              Class-Path: jar1.jar jar2.jar
              
              


              Note the path itself is relative to the root of the archive. So, for instance assuming you had an EAR structure such as

              EAR
               -->lib
               jar1.jar
               jar2.jar
              
              


              Your MANIFEST.MF should look as follows:

              
              Class-Path: lib/jar1.jar lib/jar2.jar
              
              


              Again, an entry like the one above should be placed in the MANIFEST.MF file of *each* J2EE module deployed inside your EAR file.



              • 4. Re: Where do external jar files go in the ear?
                Laszlo Borsos Newbie

                Thank you for clearing this up for me, too.

                • 5. Re: Where do external jar files go in the ear?
                  Graeme Harnish Newbie

                  Thanks for the responses ... I tried your suggestion above, so my MANIFEST.MF looks like:

                  Manifest-Version: 1.0
                  Ant-Version: Apache Ant 1.7.0
                  Created-By: 1.5.0_09-b01 (Sun Microsystems Inc.)
                  Class-Path: lib/antlr.jar lib/axis-ant.jar lib/axis.jar lib/log4j-1.2.
                   8.jar lib/commons-beanutils.jar lib/commons-digester.jar lib/commons-
                   discovery-0.2.jar lib/commons-fileupload-1.1.1.jar lib/commons-fileup
                   load.jar lib/commons-io-1.2.jar lib/commons-logging.jar lib/commons-v
                   alidator.jar lib/ditchnet-tabs-taglib.jar lib/ant-antlr-1.6.3.jar lib
                   /asm-attrs.jar lib/asm.jar lib/cglib-2.1.3.jar lib/commons-collection
                   s-2.1.1.jar lib/commons-logging-1.0.4.jar lib/dom4j-1.6.jar lib/ehcac
                   he-1.2.jar lib/freemarker.jar lib/hibernate-tools.jar lib/hibernate3.
                   jar lib/junit.jar lib/middlegen-2.0-vo.jar lib/middlegen-entitybean-p
                   lugin-2.0-vo.jar lib/middlegen-hibernate-plugin-2.0-vo.jar lib/middle
                   gen-html-plugin-2.0-vo.jar lib/middlegen-jdo-plugin-2.0-vo.jar lib/mi
                   ddlegen-servlet-plugin-2.0-vo.jar lib/middlegen-struts-plugin-2.0-vo.
                   jar lib/jakarta-oro.jar lib/jaxb-api.jar lib/jaxb-impl.jar lib/jaxb-l
                   ibs.jar lib/jaxb-xjc.jar lib/relaxngDatatype.jar lib/xsdlib.jar lib/j
                   axrpc.jar lib/jstl.jar lib/mail.jar lib/saaj.jar lib/sdrc_evista.jar
                   lib/sdrc_evista_cnf.jar lib/sdrc_evista_edt.jar lib/standard.jar lib/
                   struts.jar lib/sdrc_evista.jar lib/sdrc_evista_cnf.jar lib/sdrc_evist
                   a_edt.jar lib/teamcenter_es.jar lib/teamcenter_es_omf.jar lib/teamcen
                   ter_es.jar lib/teamcenter_es_omf.jar lib/wlclient.jar lib/wsdl4j-1.5.
                   1.jar lib/xdoclet-1.2.3.jar lib/xdoclet-apache-module-1.2.3.jar lib/x
                   doclet-bea-module-1.2.3.jar lib/xdoclet-ejb-module-1.2.3.jar lib/xdoc
                   let-hibernate-module-1.2.3.jar lib/xdoclet-java-module-1.2.3.jar lib/
                   xdoclet-jboss-module-1.2.3.jar lib/xdoclet-jmx-module-1.2.3.jar lib/x
                   doclet-web-module-1.2.3.jar lib/xdoclet-xdoclet-module-1.2.3.jar lib/
                   xjavadoc-1.1.jar
                  
                  


                  And my lib files are in:

                  EAR
                   -->lib
                   jar1.jar
                   jar2.jar
                  


                  Which is the root of my EAR file. I'm still receiving this error when deploying:

                  09:34:28,227 WARN [EJBDeployer] Verify failed; continuing
                  java.lang.NoClassDefFoundError: COM/metaphasetech/tfw/MfailException

                  Or other deployments lead to similiar errors (I can see the correct jar in the lib folder, so I know it's a CP issue and not a missing file issue)

                  Is there something else I'm doing wrong?

                  Thanks.



                  • 6. Re: Where do external jar files go in the ear?
                    Graeme Harnish Newbie

                    Interesting ... it works for .JAR files, but not .EAR files. For reference here's how to generate the MANIFEST.MF using Ant

                    http://blog.refactor.se/2006/02/13/manifestmf-classpath-from-ant/

                    Is there anyway to have the EJB Jar recognize the lib's in the main EAR?

                    Thanks, Graeme.

                    • 7. Re: Where do external jar files go in the ear?
                      Weston M. Price Master

                       


                      Interesting ... it works for .JAR files, but not .EAR files.


                      Could you explain what you mean by this? I am assuming you added the Class-Path: entry to the EJB.jar files MANIFEST.MF.



                      • 8. Re: Where do external jar files go in the ear?
                        Graeme Harnish Newbie

                         

                        "weston.price@jboss.com" wrote:

                        Interesting ... it works for .JAR files, but not .EAR files.


                        Could you explain what you mean by this? I am assuming you added the Class-Path: entry to the EJB.jar files MANIFEST.MF.



                        I did, but I found that to be unnecessary. Just so long as I put my lib files in the Jar file (under the root/lib) JBoss was then able to see the lib files on deploy. My manifest.mf file doesn't reflect any class path options. Does JBoss introspect that folder on default?

                        - Graeme.

                        • 9. Re: Where do external jar files go in the ear?
                          Weston M. Price Master

                          Which version of JBoss? 4.0.x might. The MANIFEST.MF way to do this is preferred being that this is the 'standard'. EE 5 cleans this up with a standard location at the EAR level.

                          • 10. Re: Where do external jar files go in the ear?
                            Graeme Harnish Newbie

                             

                            "weston.price@jboss.com" wrote:
                            Which version of JBoss? 4.0.x might. The MANIFEST.MF way to do this is preferred being that this is the 'standard'. EE 5 cleans this up with a standard location at the EAR level.


                            I'm using the latest GA release 4.0.5. I'm currently not using EE 5, but the EJB 2.1 spec (I'm not sure if this matters)

                            - Graeme.

                            • 11. Re: Where do external jar files go in the ear?
                              Weston M. Price Master

                              Quick check of the code looks like it was added at some point so it will check for lib unless this check is explicitly disabled. You also have the option of overriding this in your jboss-app.xml file. It would look something along the lines of:

                              <jboss-app>
                              <library-directory>dir</library-directory>
                              </jboss-app>
                              


                              Again this is a non-standard JBoss approach but if you aren't porting your app to another environment it's probably cool.





                              • 12. Re: Where do external jar files go in the ear?
                                Graeme Harnish Newbie

                                 

                                "weston.price@jboss.com" wrote:
                                Quick check of the code looks like it was added at some point so it will check for lib unless this check is explicitly disabled. You also have the option of overriding this in your jboss-app.xml file. It would look something along the lines of:

                                <jboss-app>
                                <library-directory>dir</library-directory>
                                </jboss-app>
                                


                                Again this is a non-standard JBoss approach but if you aren't porting your app to another environment it's probably cool.





                                I see. Thanks for the help.

                                - Graeme.