2 Replies Latest reply on Feb 23, 2005 6:27 PM by Ivan Li

    Make each .war have their own classloader

    Patrick Nolanjboss Newbie

      Using Jboss 3.2.6 default server and tomcat 5.0. Due to new requirements, I need my second .war to have it's own struts implementation. I'm getting some problems with log4j and classloading:

      I started with two .wars in an .ear file. One of these .war files uses struts. Everything works and deploys fine. Then, the other .war needed struts due to new requirements.. so I packaged struts.jar and log4j into each (previously the .ear had log4j shared, so moved log4j to be packaged into both wars), and set following per jboss wiki in

      default\deploy\jbossweb-tomcat50.sar\META-INF\jboss-service.xml:
      
      <attribute name="Java2ClassLoadingCompliance">false</attribute>
      <attribute name="UseJBossWebLoader">false</attribute>


      When I start up the server, I get the below stacktrace (I'm only pasting the top of it, as the whole trace is huge).

      Any ideas on what I am doing wrong?

      10:06:35,116 ERROR [Registry] Null component jboss.web:type=JspMonitor,WebModule=//www.snippedname.net/,J2EEApplication=none,J2EEServer=none
      10:06:35,126 ERROR [BaseModelMBean] Exception invoking method addChild
      org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log
       at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532)
       at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272)
       at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:246)
       at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395)
       at org.apache.catalina.session.ManagerBase.<init>(ManagerBase.java:63)
       at org.apache.catalina.session.StandardManager.<init>(StandardManager.java:64)
       at org.apache.catalina.startup.ContextConfig.managerConfig(ContextConfig.java:315)
       at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:635)
       at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:216)
       at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4290)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
       at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:149)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.apache.catalina.core.StandardContext.init(StandardContext.java:5441)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
       at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:149)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:316)
       at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:76)
       at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:320)
       at org.jboss.web.WebModule.startModule(WebModule.java:62)
       at org.jboss.web.WebModule.startService(WebModule.java:40)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
       at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:884)
       at $Proxy18.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:414)
       at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy35.start(Unknown Source)
       at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:363)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:829)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:821)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:604)
       at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy8.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:304)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:478)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:884)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:414)
       at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy4.start(Unknown Source)
       at org.jboss.deployment.SARDeployer.start(SARDeployer.java:251)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:829)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:604)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:588)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
       at $Proxy5.deploy(Unknown Source)
       at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:407)
       at org.jboss.system.server.ServerImpl.start(ServerImpl.java:311)
       at org.jboss.Main.boot(Main.java:145)
       at org.jboss.Main$1.run(Main.java:399)
       at java.lang.Thread.run(Thread.java:534)


        • 1. Re: Make each .war have their own classloader
          H Moerker Newbie

          Hi,

          You will find the following explanation on

          http://jakarta.apache.org/commons/logging/commons-logging-1.0.4/docs/guide.html#Why%20%22xxxLogger%20does%20not%20implement%20Log%22?



          Why "xxxLogger does not implement Log"?

          Upon application startup (especially in a container environment), an exception is thrown with message 'xxxLogger does not implement Log'! What's the cause and how can I fix this problem?

          This almost always a classloader issue. Log has been loaded by a different classloader from the logging implementation. Please ensure that:

          * all the logging classes (both Log and the logging implementations) are deployed by the same classloader

          * there is only copy of the classes to be found within the classloader hierarchy. In application container environments this means ensuring that if the classes are found in a parent classloader, they are not also present in the leaf classloader associated with the application. So, if the jar is deployed within the root classloader of the container then it should be removed from the application's library.



          Best regards
          moerker

          • 2. Re: Make each .war have their own classloader
            Ivan Li Newbie

            Hi,

            Since you are using an ear file, you will need to create a jboss-app.xml in your META-INF directory which should have an entry like the following:

            <jboss-app>
             <class-loading java2ClassLoadingCompliance="false">
             <loader-repository>test.log:loader=xxx.war
            <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
             </loader-repository>
             </class-loading>
            </jboss-app>


            See the Using your own log4j.xml file - class loader scoping section at the link below for more information on creating separate logs in wars.

            http://www.jboss.org/wiki/Wiki.jsp?page=Logging

            Hope this helps.
            -Ivan