I am trying to use Log4j2 in my webapp which runs in Tomcat which has its
Security policy enabled.

While initial load of Log4j2 via Commons logging bridge I keep getting -

java.lang.NoClassDefFoundError: Could not initialize class
org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup

I have narrowed it down to the initialisation code of the class

static {

        final List<String> argsList =
ManagementFactory.getRuntimeMXBean().getInputArguments();

        JMX_SINGLETON = new
JmxRuntimeInputArgumentsLookup(MapLookup.toMap(argsList));
}

Where this code needs particular security permission to be enabled. Any
idea which permission does this need in the Tomcats catalina.policy file?

Following is the StackTrace -

java.lang.NoClassDefFoundError: Could not initialize class
org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup

        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.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.reconfigure(LoggerContext.java:420)

        at
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)

        at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)

        at
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)

        at
org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)

        at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:102)

        at
org.apache.logging.log4j.jcl.LogAdapter.getContext(LogAdapter.java:39)

        at
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42)

        at
org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)

        at
org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)

        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)

        at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:282)

        at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)

        at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)

Reply via email to