logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-1658) 2.7 - ThreadContextAccess.getThreadContextMap NPE when specifying BasicContextSelector
Date Thu, 03 Nov 2016 08:09:59 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-1658?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Remko Popma updated LOG4J2-1658:
--------------------------------
    Fix Version/s: 2.8

> 2.7 - ThreadContextAccess.getThreadContextMap NPE when specifying BasicContextSelector
> --------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1658
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1658
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.7
>         Environment: Windows, JVM 1.8.0_66
>            Reporter: Leon Finker
>            Assignee: Remko Popma
>             Fix For: 2.8
>
>
> We have a custom OSGi based application. We specify Log4jContextSelector=org.apache.logging.log4j.core.selector.BasicContextSelector.
We initialize log4j through 
> Configurator.initialize("main", logConfigPath);
> Starting from log4j2 2.7 above line fails due to NPE/ExceptionInInitializerError in LogManager
static init block. I found a work around by specifying disableThreadContextMap=true. This
is 2.7 specific change. 
> {noformat}
> Exception in thread "main" java.lang.ExceptionInInitializerError
> 	at org.apache.logging.log4j.ThreadContextAccess.getThreadContextMap(ThreadContextAccess.java:45)
> 	at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createDefaultInjector(ContextDataInjectorFactory.java:83)
> 	at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createInjector(ContextDataInjectorFactory.java:67)
> 	at org.apache.logging.log4j.core.lookup.ContextMapLookup.<init>(ContextMapLookup.java:34)
> 	at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:116)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:120)
> 	at org.apache.logging.log4j.core.config.NullConfiguration.<init>(NullConfiguration.java:32)
> 	at org.apache.logging.log4j.core.LoggerContext.<clinit>(LoggerContext.java:72)
> 	at org.apache.logging.log4j.core.selector.BasicContextSelector.<clinit>(BasicContextSelector.java:32)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
> 	at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:158)
> 	at org.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:180)
> 	at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:201)
> 	at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(LoaderUtil.java:226)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:97)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:58)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
> 	at java.lang.Class.newInstance(Class.java:442)
> 	at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:94)
> 	at org.apache.logging.log4j.core.config.Configurator.getFactory(Configurator.java:46)
> 	at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:157)
> 	at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:131)
> 	at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:101)
> 	at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:188)
> 	at com.tradingscreen.client.tradesmart.OSGiMain.initLogging(OSGiMain.java:264)
> 	at com.tradingscreen.client.tradesmart.OSGiMain.main(OSGiMain.java:86)
> Caused by: java.lang.NullPointerException
> 	at org.apache.logging.log4j.spi.ThreadContextMapFactory.createThreadContextMap(ThreadContextMapFactory.java:59)
> 	at org.apache.logging.log4j.ThreadContext.init(ThreadContext.java:222)
> 	at org.apache.logging.log4j.ThreadContext.<clinit>(ThreadContext.java:201)
> 	... 32 more
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message