Offline Instrumentation throws Exception

93 views
Skip to first unread message

ronald...@gmail.com

unread,
May 4, 2018, 5:19:56 PM5/4/18
to JaCoCo and EclEmma Users
Hi,

I am trying to start an api-service using an instrumented jar in order to run automated test cases, when the service is trying to start with jacoco agent the next exception has been thrown:

INFO [] org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean: Creating Service {http://api.enterprise.com/soap}TokenService from class com.enterprise.api.resource.soap.TokenService
java.lang.IllegalStateException: Different class names com/enterprise/api/dto/TokenRequestDTO$JaxbAccessorM_getPassword_setPassword_java_lang_String and com/enterprise/api/dto/TokenRequestDTO$JaxbAccessorM_getSecret_setSecret_java_lang_String for id 3f788295c470c3f4.
java.nio.channels.OverlappingFileLockException
at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255)
at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152)
at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1063)
at java.nio.channels.FileChannel.lock(FileChannel.java:1053)
at org.jacoco.agent.rt.internal_c13123e.output.FileOutput.openFile(FileOutput.java:69)
at org.jacoco.agent.rt.internal_c13123e.output.FileOutput.writeExecutionData(FileOutput.java:53)
at org.jacoco.agent.rt.internal_c13123e.Agent.shutdown(Agent.java:137)
at org.jacoco.agent.rt.internal_c13123e.Agent$1.run(Agent.java:54)


Steps. Please, correct me if I am doing something wrong.
1. Instrument jar file

java -jar jacoco-0.8.1/lib/jacococli.jar instrument build/libs/service-1.0.0-SNAPSHOT-fat.jar --dest build/libs/instrumented

2.Run it with JaCoCo agent in the class path

java -Djacoco-agent.output=tcpserver -Duser.timezone="UTC" -XX:MaxPermSize=512M -Xmx4G -cp /var/www/html/api/service/jacoco-0.8.1/lib/jacocoagent.jar:/var/www/html/api/service/build/libs/instrumented/service-1.0.0-SNAPSHOT-fat.jar com.enterprise.custom.metadata.ServiceRun server config-service.yml

3. When the server is trying to start the above exception mentioned is thrown.

Any idea what is whappening ? or Any hint ?

If you need any further information please let me know.

Thanks in advance.

Marc Hoffmann

unread,
May 7, 2018, 2:57:15 PM5/7/18
to jac...@googlegroups.com
Hi Ronald,

is that the full log output? Looks like you have two different
exceptions here:

1) java.lang.IllegalStateException: Different class names ...

JaCoCo internally uses a CRC64 checksum as class ids. This exception
indicates that the classes mentioned in the message actually result in
the same hash. Can you please provide the two *.class files from your
"fat.jar"? Also isn't there any stack trace for this exception?

As a workaround you can exclude one of these classes during offline
instrumentation.

2) java.nio.channels.OverlappingFileLockException

This is strange. From the stack trace JaCoCo agent uses the file output
but the command line shows you configured tcpserver. Also this typically
happens when there are two JaCoCo agents configured from different
versions at the same time. Is there more going on that we can not see in
the command line?

Regards,
-marc

Ronald B.

unread,
May 7, 2018, 6:34:08 PM5/7/18
to jac...@googlegroups.com
Hi Marc,

Thanks for the answer.

is that the full log output? Looks like you have two different exceptions here:
Yes,  that's all log output.
 

1) java.lang.IllegalStateException: Different class names ...
JaCoCo internally uses a CRC64 checksum as class ids. This exception indicates that the classes mentioned in the message actually result in the same hash.
Can you please provide the two *.class files from your "fat.jar"?
There is only one class named TokenRequestDTO.class. There is only one class named TokenRequestDTO.class. Why jacocoagent belives that two classes exits ?


Files attached TokenRequestDTO(1).class prior to instrumentation and TokenRequestDTO(2).class instrumented (Please, see attached classes) . Also I would like to mention that lombok.jar is used for Getter and Setter purpose.
  
Also isn't there any stack trace for this exception?
That's all stack trace.


2) java.nio.channels.OverlappingFileLockException
This is strange. From the stack trace JaCoCo agent uses the file output but the command line shows you configured tcpserver.
 
Also this typically happens when there are two JaCoCo agents configured from different versions at the same time.
Could you please provide me an example to illustrate this statement ?
 
Is there more going on that we can not see in the command line?

My bad. I sent the incorrect  command line for the exception that is throwing.  This is the correct one. 

java -Djacoco-agent.output=file -Djacoco-agent.destfile=/var/www/html/api/service/jacoco.exec -Duser.timezone="UTC"  -XX:MaxPermSize=512M -Xmx4G --cp /var/www/html/api/service/jacoco-0.8.1/lib/jacocoagent.jar:/var/www/html/api/service/build/libs/instrumented/service-1.0.0-SNAPSHOT-fat.jar com.enterprise.custom.metadata.ServiceRun server config-service.yml

Hope all information gather would help you to understand better my issue.

Kind Regards,

Ronald


--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/UDD5eamWUXQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/b341a1e67363a27ee07b981a8f8847df%40mountainminds.com.

For more options, visit https://groups.google.com/d/optout.

TokenRequestDTO(2).class
TokenRequestDTO(1).class

Marc Hoffmann

unread,
May 8, 2018, 5:54:19 AM5/8/18
to jac...@googlegroups.com

Hi Ronald,

these are probably two inner classes. The class files are named:

  • TokenRequestDTO$JaxbAccessorM_getPassword_setPassword_java_lang_String.class
  • TokenRequestDTO$JaxbAccessorM_getSecret_setSecret_java_lang_String.class

Do you find these classes in your JAR?

BTW: What is the reason that you use offline instrumentation? Why does the JaCoCo agent not work for you?

https://www.jacoco.org/jacoco/trunk/doc/agent.html

Regards,
-marc

You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAFLA3OBmCwc03UdkdWyODb%2BRN%2Ba_ZsvKV852vxNXVA0weSUiEw%40mail.gmail.com.

Ronald B.

unread,
May 8, 2018, 11:17:14 AM5/8/18
to jac...@googlegroups.com
Hi Marc,
 
these are probably two inner classes. The class files are named:
  • TokenRequestDTO$JaxbAccessorM_getPassword_setPassword_java_lang_String.class
  • TokenRequestDTO$JaxbAccessorM_getSecret_setSecret_java_lang_String.class
Do you find these classes in your JAR?
I didn't find that classes in the JAR file. 


BTW: What is the reason that you use offline instrumentation? Why does the JaCoCo agent not work for you?
https://www.jacoco.org/jacoco/trunk/doc/agent.html

At the beginning, we were trying to apply "on the fly instrumentation" with Eclipse IDE but the issue that we are having is that JaCoCo agent only traced code that were used to start api-service. 
Once automated test cases run over the server consuming API endpoints, NO code coverage at all is captured by JaCoCo agent. Do you have any idea why this is happening ?

Ronald.



 


To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscribe@googlegroups.com.

 

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/UDD5eamWUXQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.

Marc Hoffmann

unread,
May 8, 2018, 12:09:32 PM5/8/18
to jac...@googlegroups.com

Hi Ronald,

ok, I see. These classes are created on the fly by Jaxb. So why should they get instrumented by JaCoCo when there is no JaCoCo agent in the game? Also the second issue indicates that there is another JaCoCo agent configured for the JVM. Please double check with "ps -f" for the effective command line.

If you want us to have a deeper look (instead of wild guessing) please provide a runnable reproducer.

Regards,
-marc

To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAFLA3OBv0kRLM_P43EoHwV2e-gi70OzfeG0q9f7F9Vgp_zpBJA%40mail.gmail.com.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages