4 Replies Latest reply on Apr 10, 2008 11:55 AM by jaikiran pai

    WAR file produces commons-logging LogConfigurationException

    Peter Desjardins Newbie

      I am trying to deploy a web application on JBoss 4.2.1. This is part of the Eclipse project (the infocenter user assistance system) and I have consulted it's developers. It's not a pressing issue for them since the WAR files work under other application servers and earlier versions of JBoss. I have to support JBoss 4.2.1 though.

      The web application works perfectly under JBoss 4.0.1.sp1. When I run it under 4.2.1 I see the errors pasted at the bottom when I try to open it in a browser.

      My web searching has so far revealed that JBoss 4.2 introduced updated commons-logging and log4j versions. The WAR file contains org.apache.commons.logging_1.0.4.v200706111724.jar (version 1.0.4). I have not configured JBoss to prefer the classes included in the WAR file.

      Is this something that may be resolved by configuring JBoss to load the commons-logging classes from inside my WAR file and not it's own version? Has anyone else confronted this? Any pointer to a likely cause will be much appreciated.

      Here are things I've tried so far. None have worked.

      * Removing the commons-logging JAR file from my WAR file.

      * Adding the log4j.jar file (version 1.2.8) from JBoss 4.0.1.sp1
      to my WAR file.

      * A colleague suggested configuring the application to use Java logging
      instead of log4j. I have not had success doing this yet so I'm not
      sure whether it will solve the problem.

      The details of my system are:
      JBoss version - 4.2.1.GA (no modifications from downloaded zip)
      OS - Windows XP
      Java version - jdk1.5.0_14

      My WEB-INF/jboss-web.xml file contains this:

      <jboss-web>
      <class-loading>
      <loader-repository>com.example:archive=nexus-5-0-admin.war</loader-repository>
      </class-loading>
      </jboss-web>

      Thanks.

      Peter Desjardins

      ********* ERRORS *********

      2008-04-08 12:50:53,264 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@11d5b39, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@342b99{ url=null ,addedOrder=0}
      2008-04-08 12:50:53,280 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/nexus-5-0-admin].[equinoxbridgeservlet]] Servlet.service() for servlet equinoxbridgeservlet threw exception
      org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@d54d3f for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@d54d3f for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
      at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
      at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
      at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
      at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
      at org.apache.jasper.servlet.JspServlet.(JspServlet.java:58)
      at org.eclipse.equinox.jsp.jasper.JspServlet.(JspServlet.java:60)
      at org.eclipse.equinox.jsp.jasper.registry.JSPFactory.create(JSPFactory.java:54)
      at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:262)
      at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
      at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.initializeDelegate(ServletManager.java:194)
      at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:179)
      at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
      at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
      at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:75)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:115)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@d54d3f for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)
      at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:413)
      at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
      ... 34 more
      Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
      at java.lang.Class.getConstructor0(Class.java:2671)
      at java.lang.Class.getConstructor(Class.java:1629)
      at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
      ... 35 more

        • 1. Re: WAR file produces commons-logging LogConfigurationExcept
          jaikiran pai Master

           

          * Removing the commons-logging JAR file from my WAR file.


          Do you see the same error when you remove the jar from you war? Or do you see some different error?


          • 2. Re: WAR file produces commons-logging LogConfigurationExcept
            Peter Desjardins Newbie

            Sorry, I should have posted that. If I remove org.apache.commons.logging_1.0.4.v200706111724.jar from WEB-INF/eclipse/plugins/, the server starts with no errors. Then if I open the application in a browser, the application is not available (or at least the index.jsp page is not). This is what I see in the browser:

            ***********************************************
            HTTP Status 404 - ProxyServlet: /nexus-5-0-admin/index.jsp

            type Status report

            message ProxyServlet: /nexus-5-0-admin/index.jsp

            description The requested resource (ProxyServlet: /nexus-5-0-admin/index.jsp) is not available.
            JBossWeb/2.0.0.GA
            ***********************************************

            Attempting to open that index.jsp does not produce any ERROR or WARN messages in the log.

            Thanks for your help.

            Peter

            • 3. Re: WAR file produces commons-logging LogConfigurationExcept
              Peter Desjardins Newbie

              In case it's interesting, here's what happens when I add the log4j.jar file from JBoss 4.0.1sp1 to the WEB-INF/lib/ directory of the WAR file. That version of log4j.jar is 1.2.8. and I took it from \jboss-4.0.1sp1\server\default\lib\. I am assuming that it is the version of log4j being used when my application runs successfully under JBoss 4.0.1.

              When I start the 4.2.1. server, these errors are written in the log:

              2008-04-09 10:04:31,921 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@5f634c, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@6e10d8{ url=null ,addedOrder=0}
              2008-04-09 10:04:31,921 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.appender.FileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
              2008-04-09 10:04:31,921 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
              2008-04-09 10:04:31,921 ERROR [STDERR] log4j:ERROR [org.jboss.mx.loading.UnifiedClassLoader3@19c18ae{ url=file:/C:/jboss-4.2.1.GA/server/default/tmp/deploy/tmp47679nexus-5-0-admin-exp.war/ ,addedOrder=42}] whereas object of type
              2008-04-09 10:04:31,921 ERROR [STDERR] log4j:ERROR "org.jboss.logging.appender.FileAppender" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoader@1de3f2d].
              2008-04-09 10:04:31,921 ERROR [STDERR] log4j:ERROR Could not instantiate appender named "FILE".

              • 4. Re: WAR file produces commons-logging LogConfigurationExcept
                jaikiran pai Master

                 

                When I start the 4.2.1. server


                Peter,

                Starting JBoss-4.2.x its become easier to deploy your own version of log4j as part of your application packaging. Follow these thread for details

                http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125223

                http://www.jboss.com/index.html?module=bb&op=viewtopic&t=132050

                As far as including the commons-logging jar in your application is concerned, i havent given it a try, but i guess with the classloader scoping enabled (as mentioned in those 2 threads), it should not cause any problems.

                Let us know how it goes. If you still see issues, please post back with the details.