[ 
https://issues.apache.org/jira/browse/LOG4J2-477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13856224#comment-13856224
 ] 

Tal Liron edited comment on LOG4J2-477 at 12/24/13 9:17 AM:
------------------------------------------------------------

I'm sorry, but this is still not fixed. Here is the new stack trace (built from 
TRUNK):
{code}
java.lang.NullPointerException
        at 
org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:187)
        at 
org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:145)
        at 
org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:81)
        at 
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:83)
        at 
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:34)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:200)
{code}
I changed line 187 to this:
{code}
ClassLoader parent = loader != null ? loader.getParent() : null;
{code}
You're also accessing "loader" in line 222! I changed it to this:
{code}
            if (loader != null){
              CONTEXT_MAP.putIfAbsent(loader.toString(), r);
              ctx = CONTEXT_MAP.get(name).get().get();
            }
{code}
With my changes, the NPE disappeared -- but I honestly don't understand this 
code, so i don't want to suggest that my fixes are correct.


was (Author: emblemparade):
I'm sorry, but this is still not fixed. Here is the new stack trace (built from 
TRUNK):
{code}
java.lang.NullPointerException
        at 
org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:187)
        at 
org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:145)
        at 
org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:81)
        at 
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:83)
        at 
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:34)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:200)
{code}
You're also accessing "loader" in line 222!

> NPE in ClassLoaderContextSelector
> ---------------------------------
>
>                 Key: LOG4J2-477
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-477
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 2.0-beta9
>            Reporter: Tal Liron
>            Assignee: Remko Popma
>
> The problem is that some classes don't have class loaders: this can happen 
> when working with dynamic JVM languages (Rhino, Jython, etc.)
> Here's the stack trace I got:
> {code}
> java.lang.NullPointerException
>       at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:182)
>       at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:145)
>       at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:81)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:83)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:34)
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to