You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2021/11/16 11:13:21 UTC

[Bug 65684] New: NullPointerException in Tomcat's ClassLoaderLogManager when logging.properties is empty

https://bz.apache.org/bugzilla/show_bug.cgi?id=65684

            Bug ID: 65684
           Summary: NullPointerException in Tomcat's ClassLoaderLogManager
                    when logging.properties is empty
           Product: Tomcat 8
           Version: 8.5.71
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: JULI
          Assignee: dev@tomcat.apache.org
          Reporter: roscoe@encoway.de
  Target Milestone: ----

Created attachment 38092
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38092&action=edit
Servlet to test the issue.

I am using Tomcat 8.5.71 in a docker container.

I followed the instructions from
https://logging.apache.org/log4j/2.x/log4j-appserver/index.html in order to
setup log4j2 logging configuration.

Additionally, I removed every entry from file conf/loggging.properties and
added a comment "# see: log4j2/conf/log4j2-tomcat.xml" to guide other
maintainer to the log4j2 xml.

In one webapp some business logic is done in a separate thread by using the
join-fork-threadpool. At some point, jdbc comes into play and the
mssql.jdbc:8.4.1 driver asks for a logging property.


    static boolean isActivityTraceOn() {
        LogManager lm = LogManager.getLogManager();
        String activityTrace =
lm.getProperty("com.microsoft.sqlserver.jdbc.traceactivity");
        return "on".equalsIgnoreCase(activityTrace);
    }

But a NPE is thrown in ClassLoaderLogManager.

2021-11-04T11:08:27,233 ERROR [ForkJoinPool.commonPool-worker-0] 
java.lang.NullPointerException: null
        at
org.apache.juli.ClassLoaderLogManager.findProperty(ClassLoaderLogManager.java:311)
~[tomcat-juli.jar:8.5.71]
        at
org.apache.juli.ClassLoaderLogManager.getProperty(ClassLoaderLogManager.java:291)
~[tomcat-juli.jar:8.5.71]
        at com.microsoft.sqlserver.jdbc.Util.isActivityTraceOn(Util.java:778)
~[mssql-jdbc-8.4.1.jre8.jar:?]


I debugged into the method org.apache.juli.ClassLoaderLogManager#findProperty.
In my case, the ContextClassLoader is null and info.props.isEmpty() yields
true. 

I would suggest to check if classLoader is null in the if condition in line 310
to avoid the NPE.

My workaround at the moment is to remove the conf/loggging.properties entirely.
Then everything works as expected.

I attached a servlet to test the issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 65684] NullPointerException in Tomcat's ClassLoaderLogManager when logging.properties is empty

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65684

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
Thanks for the report.

This has been fixed and the fix will be included in:
- 10.1.x for 10.1.0-M8 onwards
- 10.0.x for 10.0.14 onwards
- 9.0.x for 9.0.56 onwards
- 8.5.x for 8.5.74 onwards

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org