Problem with log4j

105 views
Skip to first unread message

Bruno Machado da Silva

unread,
May 10, 2017, 10:33:08 AM5/10/17
to JaCoCo and EclEmma Users
JaCoCo stopped working after setting the log4j.configurationFactory system property.

java.lang.reflect.InvocationTargetException
FATAL ERROR in native method: processing of -javaagent failed
    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)
Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
    at org.jacoco.agent.rt.internal_6da5971.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140)
    at org.jacoco.agent.rt.internal_6da5971.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101)
    at org.jacoco.agent.rt.internal_6da5971.PreMain.createRuntime(PreMain.java:55)
    at org.jacoco.agent.rt.internal_6da5971.PreMain.premain(PreMain.java:47)
    ... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
    at java.lang.Class.getField(Class.java:1703)
    at org.jacoco.agent.rt.internal_6da5971.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
    ... 9 more
Exception in thread "main" 
VM Args:
-Dlog4j.configurationFactory=mytest.CustomConfigurationFactory
-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager
-Dcom.sun.management.jmxremote.rmi.port=9090
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=9090
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.local.only=false
-Djava.rmi.server.hostname=localhost
-javaagent:/path/jacocoagent.jar=destfile=C:/TEMP/jacoco.exec,jmx=true

I'm using:

  • JaCoCo 0.7.7
  • Log4j 2.8.1
  • JDK 1.8.0_102
I've read about an error like that with JaCoCo and JDK 1.8, but it was already solved in JaCoCo 0.7.7.
Does anyone know how to solve it?

Evgeny Mandrikov

unread,
May 10, 2017, 3:26:53 PM5/10/17
to JaCoCo and EclEmma Users
Hi Bruno,

First of all - thank you for your report with details.
Based on these details I was able to reproduce your issue using following simplified example, and even with latest version of JaCoCo (0.7.9 as of today):

$ ls libs/
log4j-api-2.8.1.jar  log4j-core-2.8.1.jar  log4j-jul-2.8.1.jar

$ cat log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
  <Loggers>
    <Root level="debug"/>
  </Loggers>
</Configuration>

$ java -cp 'libs/*':. \
    -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager \
    -javaagent:jacocoagent.jar=jmx=true

This reminded me some recent reports about problems with "jmx=true" that unfortunately were not investigated deeply ( https://groups.google.com/d/msg/jacoco/9Q0zLzYnOJo/7pcaJn7xCAAJ ).
And example described above works when JaCoCo agent is used without "jmx=true" (or with "jmx=false").

Now that we have simple reproducer, we will definitely investigate what's going on between logging, JMX and JaCoCo, but this will take some time.
So that in the meantime - could you please try to use JaCoCo agent without "jmx=true" and report back whether this works for you?

Regards,
Evgeny

Evgeny Mandrikov

unread,
May 11, 2017, 6:26:23 AM5/11/17
to JaCoCo and EclEmma Users
And here is a ticket for a fix on JaCoCo side that explains what happens - https://github.com/jacoco/jacoco/issues/531

Regards,
Evgeny

Bruno Machado da Silva

unread,
May 11, 2017, 9:46:34 AM5/11/17
to JaCoCo and EclEmma Users
First of all, thank you so much. We were stuck in it.
As you gave us as option, we changed the way to getting report, from a JVM process, from JMX/RMI to TCP and everything has been resolved.
If we use the option "jmx=false" everything get fine.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages