question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

log4j using by the agent will attempt to loading the application's log4j2 class, leads to ClassNotFoundException

See original GitHub issue

the log here

ERROR StatusLogger Unable to create custom ContextSelector. Falling back to default.
 java.lang.ClassNotFoundException: org/apache/logging/log4j/core/async/AsyncLoggerContextSelector
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.util.LoaderUtil.loadClass(LoaderUtil.java:168)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.util.LoaderUtil.newInstanceOf(LoaderUtil.java:207)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOf(LoaderUtil.java:228)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.util.LoaderUtil.newCheckedInstanceOfProperty(LoaderUtil.java:253)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.util.Loader.newCheckedInstanceOfProperty(Loader.java:338)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.impl.Log4jContextFactory.createContextSelector(Log4jContextFactory.java:98)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.impl.Log4jContextFactory.<init>(Log4jContextFactory.java:59)
	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 co.elastic.apm.agent.shaded.apache.logging.log4j.LogManager.<clinit>(LogManager.java:94)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.spi.ThreadContextMapFactory.createThreadContextMap(ThreadContextMapFactory.java:99)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.ThreadContext.init(ThreadContext.java:225)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.ThreadContext.<clinit>(ThreadContext.java:203)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createDefaultInjector(ContextDataInjectorFactory.java:83)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createInjector(ContextDataInjectorFactory.java:67)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.lookup.ContextMapLookup.<init>(ContextMapLookup.java:34)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:120)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.lookup.Interpolator.<init>(Interpolator.java:87)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.config.ConfigurationFactory.<init>(ConfigurationFactory.java:133)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.config.ConfigurationFactory$Factory.<init>(ConfigurationFactory.java:354)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.config.ConfigurationFactory$Factory.<init>(ConfigurationFactory.java:354)
	at co.elastic.apm.agent.shaded.apache.logging.log4j.core.config.ConfigurationFactory.<clinit>(ConfigurationFactory.java:131)
	at co.elastic.apm.agent.logging.LoggingConfiguration.init(LoggingConfiguration.java:198)
	at co.elastic.apm.agent.impl.ElasticApmTracerBuilder.<init>(ElasticApmTracerBuilder.java:92)
	at co.elastic.apm.agent.bci.ElasticApmAgent.initialize(ElasticApmAgent.java:127)
	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 co.elastic.apm.agent.bci.AgentMain.init(AgentMain.java:100)
	at co.elastic.apm.agent.bci.AgentMain.premain(AgentMain.java:54)
	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.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
	at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
CoderLan0668commented, Jul 30, 2020

Thanks for reporting! Which agent version are you using? This error seems to be handled by using a default context selector instead. Besides this log message, is there anything not working as expected?

the agent not working, No Class has been retransformed. the agent was built from master branch, lastest comit is 518afc790674f311b00fb188fe2444b1a6a81a6a

1reaction
CoderLan0668commented, Aug 3, 2020

@eyalkoren The error logs has gone, and the agent work well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.NoClassDefFoundError: org/apache/log4j/Logger ...
This indicates that we were trying to load the class definition, and the class did not exist on the classpath. java.
Read more >
Log4j User Guide (PDF) - Apache Logging Services
Log4j uses the classes shown in the diagram below. Applications using the Log4j 2 API will request a Logger with a specific name...
Read more >
Apache Log4j Vulnerability CVE-2021-44228 Raises ...
Juniper Threat Labs describes the exploit variations of the Apache Log4j CVE-2021-44228 vulnerability that lead to Remote Code Execution.
Read more >
What is Apache Log4J Vulnerability and How to Prevent It?
This is a tool that injects a Java agent into a running JVM process. The agent will attempt to patch the lookup() method...
Read more >
Caused By: java.lang.NoClassDefFoundError: org/apache ...
apache.log4j.Logger class in your application's CLASSPATH. The simplest reason for this error is the missing log4j.jar file. Since org.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found