3 Replies Latest reply on Mar 13, 2012 6:40 AM by Wolf-Dieter Fink

    EAR file best practice

    Aman Varma Newbie

      Hi Guys,


      I have a basic question on EAR file archiving.


      There are lot of dependency jars as part of our application.

      1. Hibernate jar
      2. Spring jar
      3. Apache commns jar
      4. JDom.jar
      5. Struts.jar

      and lot more


      There could be 2 approches here.


      1. Include all these dependency jars in the ear file .
      2. Dependency jars should be copied to a specific location (app_lib) and referred in the classpath.


      What is the best practice and what are the pros & cons of both approches.
      Any help will be appreciated.



        • 1. Re: EAR file best practice
          Wolf-Dieter Fink Master

          Problem is that you have to isolate such JARs if they are also provided by JBoss

          If you meant with 2. the location in a lib directory of JBoss you might get the wrong class in such case.


          So I would recommend to add a class-loader scope to jboss.xml in your ear and include the jar's.


          I suppose you use AS4/5/6/ and not AS7.

          • 2. Re: EAR file best practice
            Aman Varma Newbie

            Thanks a lot wolf-dieter..


            We are using JBoss 6.1.

            Dont you think including all jars to the ear will increase the ear size.


            If we dont include the jars, then in all env ( qa, preprod, prod), we have to copy these jars to some location  and give referemce to that.


            So what's the best practice?

            • 3. Re: EAR file best practice
              Wolf-Dieter Fink Master

              As I mentioned I suppose you run into class-loading problems if you add libraries to the common lib directory.

              Set a independent classpath like java-app is not possible inside the JEE server (if you meant that by 'some localtion').


              If it is only one application there is no difference whether you deploy inside or outside the EAR.

              If you have more than one EAR uses the same libraries you might add all that JBoss not provide to the lib directory.

              With i.e. hibernate is won't work, so this must be packed inside the EAR. A better solution might be to change the application and use the provided hibernate if possible.