Dushyant-GitHub opened a new issue, #3504:
URL: https://github.com/apache/logging-log4j2/issues/3504

   ### Problem Description
   Our web application, which runs in Tomcat 11 and Java 21, uses **SLF4J + 
Logback** for logging. However, it allows dynamically importing extensions 
along with JARs at runtime using the server **classloader**. One of these 
extensions depends on `log4j-api-2.17.1.jar`, which is correctly present in the 
classpath.
   
   After deploying the extension, **calling a service that uses Log4j results 
in the following error:**
   
   `java.lang.NoClassDefFoundError: org/apache/logging/log4j/spi/ExtendedLogger`
   
   However, other Log4j classes, such as `LogManager` and `Logger`, are loading 
without issues.
   
   ### Environment Details
   
   - **Application Type** : WAR-based Java web application
   
   - **Application Server** : Apache Tomcat 11
   
   - **Java Version** : 21
   
   - **Logging Framework in Main App** : SLF4J with Logback
   
   - **Extension Support** : Allows dynamic loading of JARs at runtime using 
the server classloader
   
   - **Problematic Dependency** : log4j-api-2.17.1.jar (used by an extension)
   
   ### Debugging Steps & Findings
   
   1. Verified that `log4j-api-2.17.1.jar` is present in the classpath and 
contains `org/apache/logging/log4j/spi/ExtendedLogger.class`.
   2. Checked for multiple versions of `log4j-api` dependency in our 
application. **Result** : Only one instance of log4j-api-2.17.1.jar is found.
   3. Printed the class loaders for Log4j classes:
        ``` 
        System.out.println(org.apache.logging.log4j.LogManager.class);
        System.out.println(org.apache.logging.log4j.Logger.class);
        System.out.println(org.apache.logging.log4j.spi.ExtendedLogger.class);  
        ```
   **Result**:
   `LogManager` and `Logger` printed correctly.
   `ExtendedLogger.class` throws `NoClassDefFoundError`.
   
   ### Additional Notes
   
   - **Same application worked in Tomcat 9 without requiring a restart.**
   
   - **Tomcat 11 requires a restart for `ExtendedLogger` to be found.**
   
   - **After restarting Tomcat 11, everything works correctly.**
   
   ### Request for Help
   
   We need guidance on :
   
   - Why is `ExtendedLogger` missing, even though other Log4j classes load fine?
   
   - Does Tomcat 11’s classloader affect Log4j differently compared to Tomcat 9?
   
   - Are there additional configurations we should try in Tomcat 11?
   
   
   Would appreciate any insights from the community! 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to