3 Replies Latest reply on Jun 19, 2013 1:15 AM by sfcoy

    Classloading configuration for JBoss eap 6 excluding JBoss modules outside the war file

    neilharper

      Hi,

       

      I would like the modules in my war file to take precedence over those in the web server. There doesnt seem to be an overriding way to do it in the new classloading framework because there are certain "implicit dependencies" that are added automatically by JBoss EAP 6.

       

      However modules can be excluded by putting a file called jboss-deployment-structure.xml in the WEB-INF of the war file. Then I can configure exclusions specific inside that.

       

      Now I have a firm requirement that our web-server independent war file should not contain any configuration specific to the server which runs it.

       

      Is there any where that I can exclude these dependencies outside the war file? eg. is there any way to tell JBoss when I am deploying the war about the exclusion without it being embedded in the war?

       

      any help would be greatly appreciated.

       

      thanks

        • 1. Re: Classloading configuration for JBoss eap 6 excluding JBoss modules outside the war file
          sfcoy

          Which modules are you talking about exactly?

           

          For historical reasons, jars in WEB-INF/lib directories already take precedence (in general) over other classes that may be made available by the application server.

          1 of 1 people found this helpful
          • 2. Re: Classloading configuration for JBoss eap 6 excluding JBoss modules outside the war file
            neilharper

            Thanks for the reply yes it would be nice if WEB-INF/lib did take precedence. However the new classloader in EAP 6 loads a bunch of JBoss classes first.

             

            from https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

            In order of highest priority to lowest priority

            1. System Dependencies - These are dependencies that are added to the module automatically by the container, including the Java EE api's.
            2. User Dependencies - These are dependencies that are added through jboss-deployment-structure.xml or through the Dependencies: manifest entry.
            3. Local Resource - Class files packaged up inside the deployment itself, e.g. class files from WEB-INF/classes or WEB-INF/lib of a war.
            4. Inter deployment dependencies - These are dependencies on other deployments in an ear deployment. This can include classes in an ear's lib directory, or classes defined in other ejb jars.

             

            For 1 specific example of a module, my code is using module org.slf4j v1.6.1 which it normaly (for other web servers) picks up from spring jar in my WEB-INF/lib/com.springsource.slf4j.api.jar

             

            When running under jboss, it automatically loads v1.7.2 which turns out to have slightly different behaviour and crashes in one instance.

             

            So I can exclude slf4j in the boss-deployment-structure.xml but I have a requirement to be able to specify this dependency outside the war like I can for other web servers like tomcat.

             

            I am hoping that I have got something wrong here?

            • 3. Re: Classloading configuration for JBoss eap 6 excluding JBoss modules outside the war file
              sfcoy

              You're right. slf4j seems to fall outside that "in general" bucket. Personally, I'm not sure if I like that or not.

               

              Now, I'm interested in your statement:

              {quote}Now I have a firm requirement that our web-server independent war file should not contain any configuration specific to the server which runs it.{quote}

              I have personally worked on vendor independent JavaEE solutions for many years and they have always included vendor dependent deployment descriptors. It has been pretty much impossible to build non-trivial solutions without them.

               

              For example, a webapp that runs on JBossAS, WebSphere and WebLogic would contain:

              • web.xml (vendor independent)
              • jboss-web.xml
              • jboss-classloading.xml (sometimes on EAP5.x)
              • weblogic.xml
              • ibm-web-bnd.xml
              • ibm-web-ext.xml

               

              At the very least, this is the only way you can map vendor independent JNDI ENC names (java:comp/env/jdbc/myDataSource) to vendor dependent JNDI names.

               

              So, I'm not sure that this requirement is achievable for any non-trivial application.