[
https://issues.apache.org/jira/browse/LOG4J2-2327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16455453#comment-16455453
]
Ralph Goers commented on LOG4J2-2327:
-------------------------------------
Possibly the same. But with your fix if I have Log4j in the tomcat class loader
and the Provider in the web app it will fail as you told it to only use the
class loader from where Log4j came from. However, if the resource is in the web
app class loader it should work because the web app class loader has the tomcat
class loader as its parent, so the class should be reachable. The opposite
would not be true. The problem is that ServiceLoader, by default, uses the
thread context class loader and what that points to varies from one application
to another, so you can never count on it working. Instead, you have to
construct the search hierarchy yourself.
> java.util.ServiceConfigurationError:
> org.apache.logging.log4j.util.PropertySource: Provider
> org.apache.logging.log4j.util.EnvironmentPropertySource not a subtype
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: LOG4J2-2327
> URL: https://issues.apache.org/jira/browse/LOG4J2-2327
> Project: Log4j 2
> Issue Type: Bug
> Components: API
> Affects Versions: 2.11.0
> Reporter: Gary Gregory
> Assignee: Gary Gregory
> Priority: Major
> Fix For: 3.0.0, 2.11.1
>
>
> java.util.ServiceConfigurationError:
> org.apache.logging.log4j.util.PropertySource: Provider
> org.apache.logging.log4j.util.EnvironmentPropertySource not a subtype
> {noformat}
> Caused by: java.util.ServiceConfigurationError:
> org.apache.logging.log4j.util.PropertySource: Provider
> org.apache.logging.log4j.util.EnvironmentPropertySource not a subtype
> at java.util.ServiceLoader.fail(ServiceLoader.java:239)
> at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
> at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
> at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
> at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
> at
> org.apache.logging.log4j.util.PropertiesUtil$Environment.<init>(PropertiesUtil.java:319)
> at
> org.apache.logging.log4j.util.PropertiesUtil$Environment.<init>(PropertiesUtil.java:310)
> at
> org.apache.logging.log4j.util.PropertiesUtil.<init>(PropertiesUtil.java:59)
> at
> org.apache.logging.log4j.core.appender.ConsoleAppender$Target.getCharset(ConsoleAppender.java:92)
> at
> org.apache.logging.log4j.core.appender.ConsoleAppender$Target$1.getDefaultCharset(ConsoleAppender.java:76)
> at
> org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:225)
> at
> org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:192)
> at
> org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
> at
> org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)
> at
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
> at
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617)
> at
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)
> at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)
> at
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
> at
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
> at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
> at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:122)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
> at
> org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
> at
> org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
> at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
> at com.hsntech.hif.logging.HIFLogMessage.getLogger(HIFLogMessage.java:46)
> at com.hsntech.hif.logging.HIFLogger.<init>(HIFLogger.java:35)
> at
> com.hsntech.hif.webservice.HansenIntegrationWS.<init>(HansenIntegrationWS.java:69)
> 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:423)
> at java.lang.Class.newInstance(Class.java:442)
> at
> org.jboss.wsf.stack.cxf.configuration.BusHolder.newInstance(BusHolder.java:313)
> at
> org.jboss.wsf.stack.cxf.configuration.BusHolder.configure(BusHolder.java:211)
> at
> org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.startDeploymentBus(BusDeploymentAspect.java:97)
> at
> org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:59)
> at
> org.jboss.as.webservices.deployers.AspectDeploymentProcessor.deploy(AspectDeploymentProcessor.java:73)
> at
> org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
> ... 5 more
> {noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)