Uploaded image for project: 'Commons Logging'
  1. Commons Logging
  2. LOGGING-114

Silent Swallowing of NoClassDefFoundError

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Duplicate
    • 1.1.0
    • 1.1.1
    • None
    • Various OSs, in combination with log4j 1.2.14.

    Description

      Hi. I'm using commons logging with log4j; my team ship a library which uses log4j, and some of our clients use it with commons-logging.

      If commons-logging is in its default configuration, and log4j is present but fails to load its configuration with an unhandled exception, the results are pretty nasty:

      • commons-logging silently swallows the exception and logs with something else. If diagnostics are turned on, the message is:
        Could not instantiate Log 'org.apache.commons.logging.impl.Log4JLogger' – java.lang.reflect.InvocationTargetException: null
      • future attempts to use log4j directly get a pretty unhelpful error:
        java.lang.NoClassDefFoundError at org.apache.log4j.Logger.getLogger(Logger.java:117).

      I realise you're trying to deal with a very large number of cases in this code, but it does seem like something better could be done here. If nothing else is possible, at least recognising the InvocationTargetException and pulling out the target exception for the diagnostic log would have helped with tracking this one down.

      Attachments

        Issue Links

          Activity

            People

              dennisl@apache.org Dennis Lundberg
              mcleaton Malcolm Cleaton
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: