Uploaded image for project: 'Dev - Nexus'
  1. Dev - Nexus
  2. NEXUS-1307

SLF4JBridgeHandler causes infinite logging loop and StackOverFlowError on Glassfish

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.0.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Deploying Nexus on Glassfish fails with a StackOverFlowError in the admin console. This exception is not logged, so I had to attach a debugger to find out what happened.

      I found out that Glassfish overrides System.out to with a custom PrintWriter that redirects to the Java Logging system. They probably thought this was a smart trick to catch the output of any code that writes to System.out instead of using proper logging.

      The problem is that Nexus uses Slf4j's SLF4JBridgeHandler to redirect all JUL logging to Slf4j. Slf4j again wraps Log4J.

      Nexus configures Log4j with a ConsoleAppender writing to System.out, so what happens is this:

      1) Some code writes to a Plexus Logger component.
      2) The Plexus Logger component logs to Slf4j's Logger (in Slf4jLogger form Plexus logging)
      3) Slf4j logs to log4j
      4) log4j writes result to System.out through the configured ConsoleAppender
      5) Glassfish's custom System.out redirect console output to Java Logging
      6) Java Logging redirects it's logging to Slf4j becuse of SLF4JBridgeHandler being installed.
      7) See 3

      So we have an infinite loop in logging ending in a StackOverFlowError.

      I've confirmed that removing Slf4jHandlerInstaller from plexus.xml prevents the loop and that Nexus actually starts up on Glassfish when this change is made.

      I guess the Slf4jHandlerInstaller is probably there for a reason, so just removing it is probably not the best way to fix this.

      BTW: The Nexus FAQ states that "Glassfish is not yet supported as it conflicts with Log4j". This should probably be updated because log4j isn't really the problem here.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                eirbjo Eirik Bjørsnøs
                Last Updated By:
                Rich Seddon
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1.25h
                  1.25h