Menu

Tomcat 5.5 & DbForms logging

Help
woodchuck
2005-08-23
2013-06-03
  • woodchuck

    woodchuck - 2005-08-23

    hihi,

    i found in order to have DbForms work under Tomcat 5.5 we have to place log4j-1.2.8.jar and commons-logging-1.0.3.jar into the ${tomcat}/common/lib folder.

    is there a way to *not* have to do this?  is there a way to have the log4j-1.2.8.jar and commons-logging-1.0.3.jar files in the WEB-INF/lib folder instead?

    thanks in advance,
    woodchuck

     
    • Henner Kollmann

      Henner Kollmann - 2005-08-25

      See tomcat docs for doc of logging.

       
    • woodchuck

      woodchuck - 2005-08-25

      i think the solution requires a change in:
        - Tomcat classloading architecture
            or
        - DbForms
            or
        - both

      woodchuck

       
      • Henner Kollmann

        Henner Kollmann - 2005-08-25

        Needs changes ion tomcat - classloading is done there...

        Henner

         
        • woodchuck

          woodchuck - 2005-08-25

          easier said than done, this is for sure :)

          the classloading architecture was designed with good intentions, but in reality it is very risky to be sharing classes and jars placed in common/lib for multiple web apps.

          even the Struts documentation warns about this.

          woodchuck

           
          • Henner Kollmann

            Henner Kollmann - 2005-08-25

            Your are right - but for logging tomcat describes the things todo:

            http://jakarta.apache.org/tomcat/tomcat-5.5-doc/logging.html

            Henner

             
            • woodchuck

              woodchuck - 2005-09-02

              hihi Henner,

              just to try, i commented out *all* logging within the DbForms api.  that is, any instantiation of logCat variable like:

              private static Log logCat = LogFactory.getLog();

              and therefore also all calls using logCat.  i then recompiled this and deployed this logless DbForms to my application and yet it *still* causes Exceptions because the log4j.jar and commons-logging.jar is not in the ${Tomcat}/common/lib folder.

              i am at a loss, why does this happen even when there is no logging at all?  i really want to be able to *not* have to place log4j.jar and commons-logging.jar in ${Tomcat}/common/lib for using DbForms...

              is it because some of the (many) other jar files that we also need to deploy with DbForms require log4j.jar and the commons-logging.jar?

              the following is what the error is:

              org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog))
                  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.LogFactory.getLog(LogFactory.java:370)
                  at org.apache.catalina.core.ContainerBase.getLogger(ContainerBase.java:380)
                  at org.apache.catalina.valves.ValveBase.createObjectName(ValveBase.java:242)
                  at org.apache.catalina.core.StandardPipeline.registerValve(StandardPipeline.java:296)
                  at org.apache.catalina.core.StandardPipeline.start(StandardPipeline.java:233)
                  at org.apache.catalina.core.StandardContext.start(StandardContext.java:4045)
                  at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
                  at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
                  at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
                  at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:589)
                  at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:536)
                  at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:471)
                  at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
                  at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
                  at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
                  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
                  at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
                  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
                  at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
                  at org.apache.catalina.core.StandardService.start(StandardService.java:450)
                  at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
                  at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
                  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:585)
                  at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
                  at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
              Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog)
                  at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
                  at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
                  ... 29 more
              Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog
                  at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
                  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
                  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
                  at java.lang.Class.forName0(Native Method)
                  at java.lang.Class.forName(Class.java:164)
                  at org.apache.commons.logging.impl.LogFactoryImpl$1.run(LogFactoryImpl.java:447)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at org.apache.commons.logging.impl.LogFactoryImpl.loadClass(LogFactoryImpl.java:435)
                  at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:376)
                  ... 30 more
              Sep 1, 2005 5:28:25 PM org.apache.tomcat.util.digester.Digester endElement

              any thoughts?

              thanks in advance!

              woodchuck

               
              • Henner Kollmann

                Henner Kollmann - 2005-09-02

                What's about the ConfigLoader classs? There the logFactory is used in calls to the setLogger.

                What's happening if you put the logging jars in your application lib dir? Is it working - with just an mismatch error or is'nt?

                Henner

                 
    • woodchuck

      woodchuck - 2005-09-02

      ack!  .. you are right, i missed some... like in ConnectionFactory the log object variable is called just "cat".... 

      this time i will comment all import statements of commons log:

      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;

      and also search for all occurrences of LogFactory and check manually to make sure any static log variables are commented out (i found some that i missed because of spacing differences).

      i will compile again and see.

      but to answer your question, using the unmodified DbForms.jar my application would not work if i placed the log4j.jar and commons-logging.jar in my_app/WEB-INF/lib folder.  the Tomcat console would display Exceptions forever like an endless loop and i had to kill Tomcat (5.5.9 is the version i'm using).

      the only solution was to place log4j.jar and commons-logging.jar into ${Tomcat}/common/lib.  only after doing this would the errors go away and DbForms work properly.  but placing these 2 jars in common/lib effects all other web applications deployed on the same Tomcat instance.  i have many other web apps deployed that do not use log4j logging, and this has caused the JCL (plain Jakarta Commons Logging which uses JDK logging) logging to stop working... because it sees Log4J and just assumes this is the logging system for everything because it is in common/lib.

      woodchuck

       
      • Henner Kollmann

        Henner Kollmann - 2005-09-02

        And what's about removing only log4j? I think then commons-logging must use another logging system..

        Henner

         
        • woodchuck

          woodchuck - 2005-09-02

          hi Henner,

          i recompiled DbForms, and this time i made sure nothing relating to logging is in the code anywhere.  i commented out all import statements of org.apache.commons.logging.* and also org.apache.log4j.*

          ConfigLoader has all setLogger() statements commented out too.

          however, i still get the same Exceptions as before.

          i also tried to remove log4j.jar (only use commons-logging.jar) in both common/lib or WEB-INF/lib and both get errors during Tomcat startup.

          now, DbForms does not contain any logging... why are there still the following errors?

          INFO: Can't register valve org.apache.catalina.core.StandardContextValve@428527
          org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog))
              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.LogFactory.getLog(LogFactory.java:370)
              at org.apache.catalina.core.ContainerBase.getLogger(ContainerBase.java:380)
              at org.apache.catalina.valves.ValveBase.createObjectName(ValveBase.java:242)
              at org.apache.catalina.core.StandardPipeline.registerValve(StandardPipeline.java:296)
              at org.apache.catalina.core.StandardPipeline.start(StandardPipeline.java:233)
              at org.apache.catalina.core.StandardContext.start(StandardContext.java:4045)
              at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
              at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
              at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
              at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:589)
              at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:536)
              at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:471)
              at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
              at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
              at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
              at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
              at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
              at org.apache.catalina.core.StandardService.start(StandardService.java:450)
              at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
              at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
              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:585)
              at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
              at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
          Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog)
              at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
              at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
              ... 29 more
          Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog
              at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:164)
              at org.apache.commons.logging.impl.LogFactoryImpl$1.run(LogFactoryImpl.java:447)
              at java.security.AccessController.doPrivileged(Native Method)
              at org.apache.commons.logging.impl.LogFactoryImpl.loadClass(LogFactoryImpl.java:435)
              at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:376)
              ... 30 more
          Sep 2, 2005 2:34:42 PM org.apache.tomcat.util.digester.Digester endElement
          SEVERE: End event threw exception
          java.lang.reflect.InvocationTargetException
              at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:890)
              at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:192)
              at org.apache.tomcat.util.digester.Rule.end(Rule.java:228)
              at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1057)
              at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1241)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
              at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
              at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
              at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
              at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
              at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561)
              at org.apache.catalina.startup.ContextConfig.processDefaultWebConfig(ContextConfig.java:673)
              at org.apache.catalina.startup.ContextConfig.defaultWebConfig(ContextConfig.java:610)
              at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1030)
              at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:255)
              at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
              at org.apache.catalina.core.StandardContext.start(StandardContext.java:4053)
              at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
              at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
              at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
              at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:589)
              at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:536)
              at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:471)
              at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1102)
              at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
              at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
              at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
              at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
              at org.apache.catalina.core.StandardService.start(StandardService.java:450)
              at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
              at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
              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:585)
              at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
              at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
          Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Log4JCategoryLog))
              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.LogFactory.getLog(LogFactory.java:370)
              at org.apache.catalina.core.ContainerBase.getLogger(ContainerBase.java:380)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:996)
              at org.apache.catalina.core.StandardWrapper.start(StandardWrapper.java:1610)
              at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
              at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
              at org.apache.catalina.core.StandardContext.addChild(StandardContext.java:1894)
              ... 44 more

          could this log4j dependency come from some of the other jars that DbForms uses?

          is there anywhere else in the code that may be causing this?

          woodchuck

           
          • Henner Kollmann

            Henner Kollmann - 2005-09-02

            Yes of course.

            But seems that the apache commons logging wants to use log4j. Maybe you can configure wich logging system it should use?

            Henner

             
            • woodchuck

              woodchuck - 2005-09-02

              but i removed all logging jars from all folders (ie. no logging jars whatsoever in common/lib or WEB-INF/lib).

              and there are no code in DbForms regarding any logging at all.

              so now i don't understand:

              1)  why does commons-logging exist at all?
              2)  why is it asking for log4j?

              Tomcat 5.5.9 has a commons-logging-api.jar in the bin folder.  however, this jar does not have the Log4jFactory, Log4jCategoryLog, or Log4jLogger classes.

              so that means somehow, commons-logging.jar (not commons-logging-api.jar) is getting loaded since it knows about log4j.

              ...where could it come from?

              woodchuck

               
              • woodchuck

                woodchuck - 2005-09-02

                also, there is no code dealing with logging.  why does it insist on using log4j?  according to the documentation, commons-logging will use JDK logging if Log4j is not present...

                ...what else could be trying to set the logging system to Log4j?... i have commented out everything within DbForms api.

                woodchuck

                 
                • Henner Kollmann

                  Henner Kollmann - 2005-09-02

                  No idea!

                   
                  • woodchuck

                    woodchuck - 2005-09-02

                    i need to think of a better way to debug this, so i can find out why....

                    thx for your help tho, Henner!  :)

                    woodchuck

                     
                    • woodchuck

                      woodchuck - 2005-09-06

                      hihi Henner,

                      finally!  found the problem:

                      in ConfigServlet the initXMLValidator() function should comment the following:

                            // Map the commons-logging used by commons-validator to Log4J logger
                            try {
                               System.setProperty("org.apache.commons.logging.Log",
                                                  "org.apache.commons.logging.impl.Log4JCategoryLog");
                            } catch (java.security.AccessControlException e) {
                               logCat.warn("Unable map commons-logging to Log4j, due to SecurityManager",
                                           e);
                            }

                      i had no idea that you could even do something like this.  System.setProperty() overrided everything else i tried.  and this statement does not depend on any import packages since it is just using hard-coded strings so it avoided my initial mass commenting out all log statements attempts.

                      i'm not sure if other servlet containers will run into the same problem.  it depends on how the classloading is designed for the container.  maybe it is better to comment out this part of the code.  because each web application deployed to a servlet container should be transparent to any of the other web applications already installed.

                      once it was commented out, my whole Tomcat world was happy again.  :)  all my other web apps were not disturbed by the DbForms web app anymore.  and i had DbForms logging activated with the log4j.jar and commons-logging.jar deployed to the WEB-INF/lib folder.

                      woodchuck

                       
                      • Henner Kollmann

                        Henner Kollmann - 2005-09-06

                        Great work! I have no idea too that there is another place where logging was configured. Must be very, very old.....

                        I will comment it out and hope that the whole framework will run under the older versions too.

                        Thanks for your help
                        Henner

                         
                        • woodchuck

                          woodchuck - 2005-09-06

                          sounds great, Henner!  glad to help.  :)

                          that's what i also suspected too, at the time DbForms was created maybe this was not a problem... 

                          woodchuck

                           
              • Henner Kollmann

                Henner Kollmann - 2005-09-02

                What's about documentation of commons-logging? Can it be configured not to use log4j?

                Henner

                 

Log in to post a comment.

MongoDB Logo MongoDB