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

NoClassDefFoundError initializing PropertiesUtil in Servlet 2.5 container

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.18.0
    • None
    • API
    • None
    • Apache Tomcat/8.53

      Linux 4.14.1294-220.533.amzn2

      amd64

      JVM 1.8.0_3420-b07, Red Hat. Inc

       

    Description

      The configuration I have in Tomcat 8 and Java 1.8 with the Servlet 2.5 style initialization works in 2.17.2, but breaks in 2.18.0 (and 2.19.0) with the following exception:

      [localhost-startStop-1] Error configuring application listener of class org.apache.logging.log4j.web.Log4jServletContextListener
      java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.util.PropertiesUtil
      at org.apache.logging.log4j.status.StatusLogger.<clinit>(StatusLogger.java:78)
      at org.apache.logging.log4j.web.Log4jServletContextListener.<clinit>(Log4jServletContextListener.java:44)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      …
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4822)
      …
      

      With log4j 2.17.2, there is no exception and Log4jServletFilter initializes fine. 

      I traced class loading during the web application initialization.

      With 2.18.0, the following classes are loaded:

      • log4j.web.Log4jServletContainerInitializer log4j-web-2.18.0.jar
      • log4j.Logger log4j-api-2.18.0.jar
      • log4j.web.Log4jServletContextListener log4j-api-2.18.0.jar
      • log4j.web.Log4jWebSupport log4j-web-2.18.0.jar
      • log4j.core.LifeCycle log4j-core-2.18.0.jar
      • log4j.web.Log4jWebLifeCycle log4j-web-2.18.0.jar
      • com.ofc.data.server.MyBatisConfiguratingContextListener from classes
      • com.ofc.data.server.CleanupContextListener from classes
      • log4j.web.Log4jServletFilter log4j-web-2.18.0.jar
      • … other classes
      • log4j.spi.ExtendedLogger
      • log4j…
      • log4j.message.ParameterizedMessageFactory
      • log4j.util.Constants
      • log4j.util.PropertiesUtil
      • log4j.util.PropertySource
      • log4j.PropertySource$Comparator
      • log4j.util.BiConsumer
      • log4j.util.PropertiesUtil$Environment(Lambda)…
      • log4j.util.ServiceLoaderUtil
      • log4j.util.ServiceLoaderUtil.$ServiceLoaderSpliterator
      • java.util.ServiceConfigurationError

      With 2.17.2, it goes like this:

      • log4j.web.Log4jServletContainerInitializer log4j-web-2.17.2.jar
      • log4j.Logger log4j-api-2.17.2.jar
      • log4j.web.Log4jServletContextListener log4j-api-2.17.2.jar
      • log4j.web.Log4jWebSupport log4j-web-2.17.2.jar
      • log4j.core.LifeCycle log4j-core-2.17.2.jar
      • log4j.web.Log4jWebLifeCycle log4j-web-2.17.2.jar
      • com.ofc.data.server.MyBatisConfiguratingContextListener from classes
      • com.ofc.data.server.CleanupContextListener from classes
      • log4j.web.Log4jServletFilter log4j-web-2.17.2.jar
      • … other classes
      • org.apache.tomcat.jdbc.pool.Validator
      • log4j.spi.ExtendedLogger
      • log4j…
      • log4j.message.ParameterizedMessageFactory
      • log4j.util.Constants
      • log4j.util.PropertiesUtil
      • log4j.util.PropertySource
      • log4j.PropertySource$Comparator
      • log4j.util.BiConsumer
      • log4j.util.PropertiesUtil$Environment(Lambda)…
      • java.lang.invoke.LambdaForm$…
      • log4j.util.EnvironmentPropertySource
      • log4j.util.SystemPropertiesPropertySource
      • log4j.util.PropertiesUtil.$Environment$$Lambda

      In 2.8.0, log4j.util.PropertiesUtil.$Environment$$Lambda is loaded but not invoked.

      It looks like there are recent changes in log4j.util.PropertiesUtil.$Environment in commits aaf13561e7 Piotr Karwasz 2022-03-10, 262828b193 2022-04-13. These are changes for LOG4J2-3427.

       

      Attachments

        1. image-2022-10-27-22-59-18-736.png
          309 kB
          Nicholas Sushkin
        2. image-2023-01-04-18-53-27-006.png
          339 kB
          Nicholas Sushkin

        Issue Links

          Activity

            People

              Unassigned Unassigned
              nsushkin@openfinance.com Nicholas Sushkin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: