2 Replies Latest reply on Jan 12, 2007 4:23 AM by cinzia

    correctly packaging ear, war, har and ejb3 in jboss

    cinzia Newbie

      Hi,

      I know that some of this should go to a java forum, but I'd be grateful for any help on jboss-related issues.

      Can we state, from my understanding of JBoss class loading model (http://docs.jboss.com/jbossas/guides/j2eeguide/r2/en/html_single/#d0e1053), that:

      1) duplication of classes across apllications in not allowed.
      2) where multiple versions of the same jar are required by different applications, deployment-based scoping can be achieved by creating a loader repository with

      <loader-repository>
      in jboss-app.xml.

      If this is correct, then I structure an ear in the following way:

      application.ear
       lib/common-1.jar
       module-domain.har
       module-business.ejb3
       module-web.war
       META-INF
       MANIFEST.MF
       application.xml -->list modules war and ejb3
       jboss-app.xml --> list module har
      
      module-domain.har
       META-INF
       MANIFEST.MF
       hibernate-service.xml
       com --> structured classes dirs
      
      module-business.ejb3
       META-INF
       MANIFEST.MF --> Class-Path: ./lib/common-1.jar
       com --> structured classes dirs
      
      module-web.war
       WEB-INF
       lib
       classes
       web.xml
       jboss-web.xml
       META-INF
       MANIFEST.MF --> Class-Path: ./lib/common-1.jar
      


      Things I'm not sure:

      1) ejb3 archive uses classes in the har archive, are they visible once deployed? ejb and har use different class loaders but report to the same loader repository, so this should be a yes, right?

      2) what do/don't include in the ear lib folder:
      a) don't: jars already in jboss default/lib directory, but should they be added to the MANIFEST Class-Path?
      b) don't: jars that might be used by future apps, instead place them in default/dir
      c) do: jars needed by the particular app.
      d) do: jars of a different version of those in default/lib, in this case add <loader-repository> to jboss-app.xml to achieve isolation.


      3) if I added to the above ear: lib/dom4j-1.6.1.jar, and added it to the MANIFEST Class-Path of one of the modules, then

      a) because default/dir has already a different version dom4j.jar I should add to jboss-app.xml:
      <jboss-app>
       <loader-repository>myappname.com:loader=application.ear</loader-repository>
      </jboss-app>
      , correct?

      b) does this mean that only dom4j classes will be looked in the HeirarchicalLoaderRepository3? And that only dom4j will be isolated? Or will this apply to all jars in application.ear/lib?


      thanks for any help
      cinzia

        • 1. Re: correctly packaging ear, war, har and ejb3 in jboss
          Marco Novice

          hello,
          didnt read all the post.. it's quite long
          deploying ear in jboss is actually straightforward, allyou need to avoid, as you said, is duplication of classes
          so structure your ear:
          - war
          - ear

          jars that are commons needs to be placed outside those war/ear/
          those common jars needs to be included in the manifest file of the jar that are dependent on them

          there's no ejb3 issues, i have deployed successfuly an ejb3 app made of jar, war and ear, and didnt need to do anything.
          my build system (maven2) was taking care of classpath in manifest file

          go ahead and try to deploy your ear, and you will see that it's easier than what you think

          hth
          marco

          • 2. Re: correctly packaging ear, war, har and ejb3 in jboss
            cinzia Newbie

            thanks marco, glad I'm not too far away from the right path ;)