Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3427

ServiceLoader usage in a servlet environment

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.18.0
    • None
    • None

    Description

      It is fair to assume that a servlet container like Tomcat might contain multiple copies of Log4j 2.x:

      • a copy of Log4j 2.x can be used as logging provider for the entire server,
      • each web application can contain another copy of Log4j 2.x

      One of the shortcomings of ServiceLoader is that it detects services in both the web application's and server's classloader, but only those in the web application are usable: those in the server's classloader can not extend the service class contained in the application's classloader.

      A typical usage of ServiceLoader to find all instances of a certain service can therefore end up in a ServiceConfigurationError. Those are caught in Log4j 2.x, but usually end up in all services (also the viable ones) being discarded.

      Hence a tool is necessary to only discard those services, which are contained in the server's classloader.

      Attachments

        Activity

          People

            pkarwasz Piotr Karwasz
            pkarwasz Piotr Karwasz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: