You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Frédéric Hannes (Jira)" <ji...@apache.org> on 2025/05/08 11:48:00 UTC

[jira] [Created] (TOMEE-4485) ContextClassLoader becomes null for timer threads in TomEE 10

Frédéric Hannes created TOMEE-4485:
--------------------------------------

             Summary: ContextClassLoader becomes null for timer threads in TomEE 10
                 Key: TOMEE-4485
                 URL: https://issues.apache.org/jira/browse/TOMEE-4485
             Project: TomEE
          Issue Type: Bug
          Components: TomEE Core Server
    Affects Versions: 10.0.1
         Environment: TomEE 10.0.1 running on JRE 21 (Temurin 21.0.6+7) in Docker container (Ubuntu based). Hibernate 6.6.13 is used instead of OpenJPA.
            Reporter: Frédéric Hannes


We've been working on migrating our applications from Java EE to Jakarta EE. The applications run without any issues on TomEE 8 with Java EE and TomEE 9 with Jakarta EE. But when upgrading to TomEE 10 we notice that errors start occurring after a few JNDI lookups in a thread from the EjbTimerPool. Since we don't experience any issues on TomEE 9, I suspect it may be a bug that was introduced in TomEE 10.

It is still unclear to us what is the underlying cause of the problem and what component it pertains to, as the exception cause is in code of the Tomcat server, but the thread is managed by OpenEJB. Since the error occurred when upgrading to TomEE 10, I've logged it under TomEE, but please move the issue if needed.

The cause of the exception is a JNDI lookup that fails. In the {{ContextBindingsisClassLoaderBound()}} method in Tomcat, the context classloader of the thread is used as the key for a map. At some point the classloader of these threads in the EjbTimerPool become {{null}} and as a result we get back this {{NullPointerException}} when it tries to use it as the key for the map.
{code:java}
application-1  | Caused by: java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "<parameter1>" is null
application-1  |     at java.base/java.util.concurrent.ConcurrentHashMap.get(Unknown Source)
application-1  |     at java.base/java.util.concurrent.ConcurrentHashMap.containsKey(Unknown Source)
application-1  |     at org.apache.naming.ContextBindings.isClassLoaderBound(ContextBindings.java:302)
application-1  |     at org.apache.naming.SelectorContext.getBoundContext(SelectorContext.java:390)
application-1  |     at org.apache.naming.SelectorContext.lookup(SelectorContext.java:144)
application-1  |     at java.naming/javax.naming.InitialContext.lookup(Unknown Source)
application-1  |     at com.example.c.e.lookupNamedObject(e.java:54)
application-1  |     at com.example.a.c.a(c.java:51)
application-1  |     ... 23 more
{code}
I've not been able to pinpoint what causes the classloader to be set to {{null}} and I've not found anything in migration guides, release notes or commits that have given me much more insight into the issue so far. I am not familiar enough with the entire codebase of the TomEE ecosystem itself to efficiently diagnose the issue. But I will update this ticket if I find out anything more.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)