8 Replies Latest reply on Jul 20, 2012 1:51 AM by Marc Lorek

    JBoss 7 Exploded War and ClassLoading

    Marc Lorek Newbie

      Hi,

       

      i am looking for two solutions regarding deploying artefacts wihtin Jboss 7 (actual version, domain configuration)

       

      I have an EAR File (just containing components and some libs), a exploded war and a normal war file

       

      a) Both wars should use classes from within the ear (BOs from the components, ...). How do i manage that the war uses the ear for "class loading"? (jboss-deployment-structure.xml?)

          I dont find any config with a reference on a ear.

       

      b) How can i deploy an exploded war (just use the CLI?) Furthermore i has to be explded because our CMS will deploy JSPs into the filesystem (=exploded war).

         In that way i can avoid redeployment of the war. Actually the exploded war is on a central filesystem to avoid multiple deployments by the cms.

       

      Can anybode help me out with the two issues?

       

      Thanks and best regards,

      Marc

        • 1. Re: JBoss 7 Exploded War and ClassLoading
          Tomaz Cerar Master

          hi,

           

          a)  yes by jboss-deployment-structure.xml for more info read https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7

          b) if you use exploded war you have to copy it to standalone\deployments directory. for jsp's to reload/recompile properly you have to enable development mode for web subsystem

           

           

           

          --

          tomaz

          • 2. Re: JBoss 7 Exploded War and ClassLoading
            Marc Lorek Newbie

            Hi,

             

            thanks for the answer, but as i said i need some help by setting up the xml file. (i read already the article but found no hint how to setup a reference to an ear file).

             

            Assume i have: myportal.war and mycomponents.ear. In what sections of the xml file i have to put the reference?

             

            b) OK, it seems that it makes sense to use the domain approach for a clustered productional environment in order to use some advantages and now i have to go back to stand alone configuration as in Jboss 5.

                There is no other way?

             

            BR
            Marc

            • 3. Re: JBoss 7 Exploded War and ClassLoading
              Tomaz Cerar Master

              Hi,

               

              it looks like i have missunderstood you about the jboss-deployment-structure.xml...

              what you can do is add dependancy to deployed module.

               

              for instance    

              <dependencies>

                    <!-- Adds a dependency on a ejb jar. This could also be done with a Class-Path entry -->

                    <module name="deployment.myear.ear.myejbjar.jar" />

                  </dependencies>

              would add dependancy to myear.ear\myejbjar.jar

              aka to myejbjar.jar inside deployed myear.ear.

              There are more examples about how and what you can do in provided link.

               

              yeah problem is that when you have exploded wars deploymens cannot be "managed" so they are harder to work with in domain mode. But not imposible

              If you have(as you indicated) a shared storage where your exploded deployment is avaliable you can still manage it with CLI

              by deploying it with

              deploy --unmanaged <all-other-parameters> <path-to-deployment>

              this way it will just deploy your application from current path and wont copy it into deployments.

              for more options on what you can do with this i would recommend running deploy --help

               

              --

              tomaz

              • 4. Re: JBoss 7 Exploded War and ClassLoading
                Marc Lorek Newbie

                Hi,

                 

                ok, i can add all modules to the list and that would be a solution. Do i have to add also all lib within the ear? I might be possible that my war needs a class of a component a, which then references a class in a lib.

                I think in JBoss i changed the overall class loader so that all deployments see all classes.

                 

                To use CLI would be the best for me to use domain mode and a exploded war on a centralised path. (b is solved then )

                 

                Best regards,

                Marc

                • 5. Re: JBoss 7 Exploded War and ClassLoading
                  Marc Lorek Newbie

                  Hi,

                   

                  ok, i have still the same issue: One ear with 20 components and a some libs (ca. 15-20) and a war that should use these components AND the libs (War uses classes from the components and implicitly from the libs).

                  (Actually some NoClassDefFound Errors because i dont have the libs in the list)

                   

                  I read https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7 several times but found actually no solution except the one to put all (components and libs) each by each in the dependency list.

                   

                  IMHO is this not very attractive. Is it not possible to use the exports / filters to enhance this? If i have to add a comontent or add a lib i have to change the structure xml file within the WAR.

                   

                  Does anybody have any experience?

                   

                  PS: I also tried to "disable" the isolation of the class loader in general. I put

                   

                  <subsystem xmlns="urn:jboss:domain:ee:1.0" >           

                   

                    <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

                  </subsystem>

                   

                  in the domain.xml but it has no effect.

                   

                  BR
                  Marc

                  • 6. Re: JBoss 7 Exploded War and ClassLoading
                    Marc Lorek Newbie

                    Hi,

                     

                    ok, i investigate this issue some more days....two approaches:

                     

                    a) Generating the jboss-deployment-structure.xml (how to do it?)

                        BUT: How do i manage to access a lib within the ear from a outside war?

                     

                        Thats easy:

                     

                         <module name="deployment.myear.ear.myejbjar.jar" />    

                     

                         and a lib?

                     

                         <module name="deployment.myear.ear.lib.testjar" />    

                     

                    is not working.

                     

                    b) Putting all the libs from the ear into modules. Also not funny at all and if i think at my releasemanagement it makes things much harder. (not only rolling artefacts also rolling out possible "config changes")

                     

                    BR
                    Marc

                    • 7. Re: JBoss 7 Exploded War and ClassLoading
                      Tomaz Cerar Master

                      Hi,

                       

                      you can do dependancies to modules and for instance whole war is one module, that includes all its jar in lib...

                       

                      what you usualy want is to include just part of it by defining include/exclude filters for more you can read in class loading docs.

                       

                      that means you cannot do depdanncy just to one jar inside lib

                       

                       

                      --

                      tomaz

                      • 8. Re: JBoss 7 Exploded War and ClassLoading
                        Marc Lorek Newbie

                        Hi,

                         

                        yes, my next approach is to make modules from my own lib (jar within EAR). I set up a jboss-deployment-structure.xml file and put it in the ear, but jboss

                        throws NoClassDefFound Errors just while deploying the ear. The components dont find the classes. (War is no in focus actually)

                         

                        <?xml version="1.0" encoding="UTF-8"?>

                        <jboss-deployment-structure>

                            <!-- Make sub deployments isolated by default, so they cannot see each others classes without a Class-Path entry -->

                            <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

                            <!-- This corresponds to the top level deployment. For a war this is the war's module, for an ear -->

                            <!-- This is the top level ear module, which contains all the classes in the EAR's lib folder -->

                               

                            <deployment>

                                <dependencies>

                                <module name="de.somename.xxx"/>

                        ...

                         

                        The modules are indexed but how can i see if there are available?

                         

                        BR
                        Marc