3
votes

Im working on a project that has log4j2 as a transitive dependency. I was having this error

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

So I created a new log4j2.xml file under src/main/resources and I tried with the Default Apache's configuration.

Here:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
  <Appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
  </Appenders>
  <Loggers>
    <Root level="error">
      <AppenderRef ref="Console"/>
    </Root>
  </Loggers>
</Configuration>

Now when I build my project this warns (errors) prompts:

 2015-02-11 17:02:52,375 WARN JNDI lookup class is not available because this JRE does not support JNDI. JNDI string lookups will not be available, continuing configuration. java.lang.ClassCastException: Cannot cast org.apache.logging.log4j.core.lookup.JndiLookup to org.apache.logging.log4j.core.lookup.StrLookup
    at java.lang.Class.cast(Class.java:3133)
    at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:163)
    at org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOf(Loader.java:311)
    at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:92)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:104)
    at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:55)
    at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:375)
    at org.apache.logging.log4j.core.layout.PatternLayout.createDefaultLayout(PatternLayout.java:280)
    at org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.<init>(ConsoleAppender.java:116)
    at org.apache.logging.log4j.core.appender.ConsoleAppender.newBuilder(ConsoleAppender.java:111)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.createBuilder(PluginBuilder.java:158)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:118)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:766)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:706)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:698)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:358)
    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.mule.util.IOUtils.<clinit>(IOUtils.java:33)
    at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.getExamplesFile(JavaDocAnnotationVerifier.java:222)
    at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.validateSampleTag(JavaDocAnnotationVerifier.java:199)
    at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.validateMethod(JavaDocAnnotationVerifier.java:143)
    at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.verify(JavaDocAnnotationVerifier.java:74)
    at org.mule.devkit.verifiers.SimpleJavaDocAnnotationVerifier.verify(SimpleJavaDocAnnotationVerifier.java:17)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.doVerify(AbstractAnnotationProcessor.java:462)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.verifyModule(AbstractAnnotationProcessor.java:307)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.runVerifiers(AbstractAnnotationProcessor.java:185)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.doProcess(AbstractAnnotationProcessor.java:413)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.process(AbstractAnnotationProcessor.java:140)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
    at com.sun.tools.javac.main.Main.compile(Main.java:439)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
    at org.mule.devkit.maven.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:231)
    at org.mule.devkit.maven.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:149)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

2015-02-11 17:02:52,379 WARN JMX runtime input lookup class is not available because this JRE does not support JMX. JMX lookups will not be available, continuing configuration. java.lang.ClassCastException: Cannot cast org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup to org.apache.logging.log4j.core.lookup.StrLookup
    at java.lang.Class.cast(Class.java:3133)
    at org.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:163)
    at org.apache.logging.log4j.core.util.Loader.newCheckedInstanceOf(Loader.java:311)
    at org.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:103)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.<init>(AbstractConfiguration.java:104)
    at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:55)
    at org.apache.logging.log4j.core.layout.PatternLayout$Builder.build(PatternLayout.java:375)
    at org.apache.logging.log4j.core.layout.PatternLayout.createDefaultLayout(PatternLayout.java:280)
    at org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.<init>(ConsoleAppender.java:116)
    at org.apache.logging.log4j.core.appender.ConsoleAppender.newBuilder(ConsoleAppender.java:111)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.createBuilder(PluginBuilder.java:158)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:118)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:766)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:706)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:698)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:358)
    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.mule.util.IOUtils.<clinit>(IOUtils.java:33)
    at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.getExamplesFile(JavaDocAnnotationVerifier.java:222)
    at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.validateSampleTag(JavaDocAnnotationVerifier.java:199)
    at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.validateMethod(JavaDocAnnotationVerifier.java:143)
    at org.mule.devkit.generation.javadoc.JavaDocAnnotationVerifier.verify(JavaDocAnnotationVerifier.java:74)
    at org.mule.devkit.verifiers.SimpleJavaDocAnnotationVerifier.verify(SimpleJavaDocAnnotationVerifier.java:17)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.doVerify(AbstractAnnotationProcessor.java:462)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.verifyModule(AbstractAnnotationProcessor.java:307)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.runVerifiers(AbstractAnnotationProcessor.java:185)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.doProcess(AbstractAnnotationProcessor.java:413)
    at org.mule.devkit.apt.AbstractAnnotationProcessor.process(AbstractAnnotationProcessor.java:140)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
    at com.sun.tools.javac.main.Main.compile(Main.java:439)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
    at org.mule.devkit.maven.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:231)
    at org.mule.devkit.maven.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:149)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Currently dependency versions:

log4j2 Dependencies

What could be causing this?

Thanks in advance.

Juan c:

2

2 Answers

4
votes

This is not a problem. The Interpolator class is trying to enable various kinds of lookups: for example env:propertyName lookups for environment variables, sys:propertyName for Java system properties, jndi:propertyName for JNDI properties, etc.

If JNDI is not available you will see this warning. Configuration will continue after this message is logged.

You can raise a request on the log4j2 Jira issue tracker to make this look less like an error (with hindsight the stack trace is confusing and unnecessary here).

0
votes

Perhaps the project also loads another log4j2 configuration somewhere that depends on the JMX properties. You can get more information about what Log4j is doing by enabling DEBUG or TRACE status on your config file like shown here

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG" name="example-config">
</Configuration>

Also try setting the default StatusLogger for Log4j to DEBUG by passing in a system property when running the application:

java -DLog4jDefaultStatusLevel=DEBUG MyApp

Also, are you sure that there are no 1.2 dependencies in the classpath? If there are, they might conflict with the 1.2-2.1 bridge.