I have a Servlet 3.1 webapp running in Tomcat 8.0.32. I've upgraded from
log4j 2.1 to 2.7, and now I am getting the following error. The error
occurs in all versions >=2.4; it works when I downgrade to 2.3. As far as I
know, there is no other version of log4j on my classpath, unless Tomcat is
hiding something. None of my other depdendencies pull in log4j, as checked
by `mvn -Dverbose=true dependency:tree`.

The MapLookup.newMap method appears to be package private, but that should
be accessible to MainMapLookup, which is in the same package. Any ideas on
what I'm doing wrong?

2016-10-20 11:57:42,260 DEBUG Starting LoggerContext[name=WebappClassLoader
  context: foo
  delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@108c4c35
] from configuration at null
2016-10-20 11:57:42,260 DEBUG Starting LoggerContext[name=WebappClassLoader
  context: foo
  delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@108c4c35
, org.apache.logging.log4j.core.LoggerContext@26745914] with configuration
XmlConfiguration[location=/Users/jeremy/acme/foo/target/foo-1.0/WEB-INF/classes/log4j2.xml]...
2016-10-20 11:57:42,260 DEBUG Shutdown hook enabled. Registering a new one.
2016-10-20 11:57:42,261 DEBUG Starting configuration
XmlConfiguration[location=/Users/jeremy/acme/foo/target/foo-1.0/WEB-INF/classes/log4j2.xml]
2016-10-20 11:57:42,261 DEBUG PluginManager 'Core' found 108 plugins
2016-10-20 11:57:42,261 DEBUG PluginManager 'Level' found 0 plugins
2016-10-20 11:57:42,263 DEBUG PluginManager 'Lookup' found 14 plugins
20-Oct-2016 11:57:42.264 SEVERE [RMI TCP Connection(2)-127.0.0.1]
org.apache.catalina.core.ContainerBase.addChildInternal
ContainerBase.addChild: start:
 org.apache.catalina.LifecycleException: Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/foo]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1692)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at
org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:465)
at
org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:415)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at
javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
at
javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at
javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
at
javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
at
javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalAccessError: tried to access method
org.apache.logging.log4j.core.lookup.MapLookup.newMap(I)Ljava/util/HashMap;
from class org.apache.logging.log4j.core.lookup.MainMapLookup
at
org.apache.logging.log4j.core.lookup.MainMapLookup.<clinit>(MainMapLookup.java:37)
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
org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:185)
at
org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:65)
at
org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
at
org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
at
org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:169)
at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:204)
at
org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:110)
at
org.apache.logging.log4j.web.Log4jWebInitializerImpl.initializeNonJndi(Log4jWebInitializerImpl.java:157)
at
org.apache.logging.log4j.web.Log4jWebInitializerImpl.start(Log4jWebInitializerImpl.java:107)
at
org.apache.logging.log4j.web.Log4jServletContainerInitializer.onStartup(Log4jServletContainerInitializer.java:57)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5244)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
... 42 more

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="trace">
    <Appenders>
        <Console name="STDOUT" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %-5p [%t] %m%n"/>
        </Console>
        <Console name="XSLOUT" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %-5p [%t] %C (%F:%L) - %m%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="com.acme" level="debug" additivity="false">
            <AppenderRef ref="STDOUT"/>
        </Logger>
        <Logger name="org.apache.fop" level="warn" additivity="false">
            <AppenderRef ref="XSLOUT"/>
        </Logger>
    </Loggers>
</Configuration>

Thanks,
;; Jeremy

Reply via email to