2 Replies Latest reply on Feb 2, 2012 6:28 AM by alesj

    How to ignore specific WEB-INF/lib jars

    sfcoy

      Hi there,

       

      I've been rummaging around here for a few hours trying to figure this out.

       

      We have a web application that has been developed as a "universal" WAR file. This means that the same WAR must deploy and run on the three application servers that we support, including JBoss 5.1.

       

      This webapp contains both a log4j implementation and an slf4j implementation. This results in the following errors when the application is started:

       

       

      {code}

      2012-02-01 17:30:08,327 ERROR [STDERR] (HDScanner) log4j:ERROR A "org.jboss.logging.appender.FileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.

      2012-02-01 17:30:08,329 ERROR [STDERR] (HDScanner) log4j:ERROR The class "org.apache.log4j.Appender" was loaded by

      2012-02-01 17:30:08,330 ERROR [STDERR] (HDScanner) log4j:ERROR [BaseClassLoader@447d0c6c{vfszip:/Users/steve/servers/jboss-eap-5.1.1/server/axelerator-platform/deploy/axelerator-platform-mr-web-12.1.1-SNAPSHOT.war/}] whereas object of type

      2012-02-01 17:30:08,331 ERROR [STDERR] (HDScanner) log4j:ERROR "org.jboss.logging.appender.FileAppender" was loaded by [org.jboss.bootstrap.NoAnnotationURLClassLoader@7bd63e39].

      2012-02-01 17:30:08,332 ERROR [STDERR] (HDScanner) log4j:ERROR Could not instantiate appender named "FILE".

      2012-02-01 17:30:08,361 ERROR [STDERR] (HDScanner) SLF4J: Class path contains multiple SLF4J bindings.

      2012-02-01 17:30:08,362 ERROR [STDERR] (HDScanner) SLF4J: Found binding in [vfszip:/Users/steve/servers/jboss-eap-5.1.1/common/lib/slf4j-jboss-logging.jar/org/slf4j/impl/StaticLoggerBinder.class]

      2012-02-01 17:30:08,364 ERROR [STDERR] (HDScanner) SLF4J: Found binding in [vfszip:/Users/steve/servers/jboss-eap-5.1.1/server/axelerator-platform/deploy/axelerator-platform-mr-web-12.1.1-SNAPSHOT.war/WEB-INF/lib/slf4j-jdk14-1.5.8.jar/org/slf4j/impl/StaticLoggerBinder.class]

      {code}

       

      We prefer to use the JBoss provided implementations of these as this simplifies logging configuration for administrators.

       

      Therefore, I'd like to know if it's possible to filter out these two jars from the classloader so that they're effectively ignored in our JBoss deployment.

       

      And if so, how do we go about it?

       

      I tried adding a jboss-classloading.xml file:

       

      {code:xml}

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

      <classloading xmlns="urn:jboss:classloading:1.0"

          domain="myapp-domain"

          parent-domain="DefaultDomain"

          export-all="NON_EMPTY"

          import-all="true"

          parent-first="true"

          >

      </classloading>

      {code}

       

      but this causes other problems for us as this app uses Quartz which collides imcompatibly with the quartz version used in JBoss.

       

       

      Thanks

        • 1. Re: How to ignore specific WEB-INF/lib jars
          sfcoy

          Changing my jboss-classloading.xml file to:

           

          {code:xml}

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

          <classloading xmlns="urn:jboss:classloading:1.0"

              domain="myapp-domain"

              parent-domain="DefaultDomain"

              export-all="NON_EMPTY"

              import-all="true"

              parent-first="false"

              excluded="org.apache.log4j,org.slf4j"

              >

              <!-- Forces the use of JBoss provided log4j and slf4j implementations -->

          </classloading>

          {code}

           

          resolved my problem.

          • 2. Re: How to ignore specific WEB-INF/lib jars
            alesj

            Nice.

            I actually forgot we support this. :-)

            As I was just about to suggest you to use a custom deployer.

             

            But afair, you need to exclude all possible packages;

            e.g. org.sl4fj.acme needs to be excluded as well, if you want org.sl4j.acme.Acme to be loaded from parent

            --> it means that excluded doesn't take wildcard, but an exact name

            1 of 1 people found this helpful