1 Reply Latest reply on Oct 13, 2011 8:53 AM by Daniel Bevenius

    Logging issue in JBoss 7.0.2 Final standalone-preview

    gboro54 Novice

      I am trying to deploy an ear with a jar and war packaged in side(pretty standard). I am attempting to use Log4j in my jar which host a bunch of EJB's which are exposed as web service endpoint. When I deploy the ear I fail with the following:

       

       

      {code}

      Caused by: java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger;

                at java.lang.Class.getDeclaredFields0(Native Method) [:1.6.0_27]

                at java.lang.Class.privateGetDeclaredFields(Class.java:2291) [:1.6.0_27]

                at java.lang.Class.getDeclaredFields(Class.java:1743) [:1.6.0_27]

                at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]

                at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]

                ... 10 more

      {code}

       

      When we run another application in jboss7.0.2 standalone web logging seems to work. Any thoughts?

        • 1. Re: Logging issue in JBoss 7.0.2 Final standalone-preview
          Daniel Bevenius Master

          Hi,

           

          you'll need to declare a dependency to 'org.apache.log4j'. You can do this by adding a manifest header like this:

           

          Dependencies: org.apache.log4j
          

          Adding this dependency should enable your application to deploy but to be able to customize logging you'll need to package log4j with your deployment or as a separate deployment/module. The reason for this is that log4j needs to be initialized with your custom log4j.xml, and if you only specify a dependency to the module 'org.apache.log4j', log4j will have been initialized before your module is deployed and your custom logging configuration will not be considered. For an example of this you can take a look at this application, see the section "Custom logging" for details.

           

          Regards,

           

          /Daniel