6 Replies Latest reply on Aug 28, 2013 5:02 AM by zhouyaguo

    Question about how "jboss-deployment-structure.xml" works

    markus78

      I have a EAR which consists of a number of statless session beans and WAR's. These use log4j.jar which we have in the ear/lib directory , and to prevent JBoss  7 from adding a dependency to the server (modules) version of log4j I have to do this in my deployment-structure.xml

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-deployment-structure>
         <deployment>
           <exclusions>
             <module name="org.apache.log4j" />
           </exclusions>
         </deployment>
         <sub-deployment name="Web-SNAPSHOT.war">
           <exclusions>
             <module name="org.apache.log4j" />
           </exclusions>
         </sub-deployment>
         <sub-deployment name="XFire-SNAPSHOT.war">
           <exclusions>
             <module name="org.apache.log4j" />
           </exclusions>
         </sub-deployment>
      </jboss-deployment-structure>
      
      

       

      Why do I have to specify an exclusion in each subdeployment? Should not the "top" level exclusion make sure that nothing in my EAR uses the JBoss 7 modules version of log4j? Am I doing this wrong?

       

      BR

      /Markus

        • 1. Re: Question about how "jboss-deployment-structure.xml" works
          wdfink

          Do you add 'org.apache.log4j' to the global-modules of the standalone/domain configuration? By default log4j is not loaded.

          • 2. Re: Question about how "jboss-deployment-structure.xml" works
            markus78

            No I don't add log4j in any global module, log4j gets loaded anyway this changed somewhere between CR1b and 7.1.Final , im on Final version.

            But the main question for me is the one about the deployment-structure, why do I have to specify each subdeployment when I have the "toplevel" exclusion inplace.

            • 3. Re: Question about how "jboss-deployment-structure.xml" works
              markus78

              Im bumping this, Is it really neccesary to specify each subdeployment to exclude log4j from my ear?

              • 4. Re: Question about how "jboss-deployment-structure.xml" works
                swd847

                At the moment yes. Can you file a JIRA and I will look at fixing this?

                • 5. Re: Question about how "jboss-deployment-structure.xml" works
                  markus78
                  • 6. Re: Question about how "jboss-deployment-structure.xml" works
                    zhouyaguo

                    A late reply, but hope it helps:

                     

                    Alternative is that you can hack the code as follows:

                    diff --git a/server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecProcessor.java b/server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecProcessor.java

                    index b4a168e..798a638 100644

                    --- a/server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecProcessor.java

                    +++ b/server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecProcessor.java

                    @@ -91,6 +91,11 @@ public class ModuleSpecProcessor implements DeploymentUnitProcessor {

                     

                     

                             // Add internal resource roots

                             final ModuleSpecification moduleSpec = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);

                    +

                    +        // make org.apache.log4j module excluded by default. we always take along our own log facade and log configuration file, so we should tell AS not to take over logging of ear or war

                    +        // Yaguo Zhou

                    +        moduleSpec.addExclusion(ModuleIdentifier.create("org.apache.log4j"));

                    +

                             final List<ResourceRoot> resourceRoots = new ArrayList<ResourceRoot>();

                             if (ModuleRootMarker.isModuleRoot(mainRoot)) {

                                 resourceRoots.add(mainRoot);

                    so that we don't need jboss-deployment-structure.xml anymore in your deployment.

                     

                    If you don't want AS to scan logging configuration file in your deployment, remember to set -Dorg.jboss.as.logging.per-deployment=false