Hi Abhay,

yes, you would need to remove those duplicate from the ear .You can also unzip 
the ear file, remove the 3rd party JAR from the file system and then run the 
report generator with this folder.

Note that this is only an issue with reporting. Multiple different classes can 
be handled at instrumentation and runtime. Excluding such classes from 
instrumentation does not fix the report.

Regards,
-marc

> On 14. Dec 2020, at 11:59, Abhay Hegde <[email protected]> wrote:
> 
> Thank you Marc. 
> When I try that, i am faced with :
> 
> Exception in thread "main" java.io.IOException: Error while analyzing 
> ../myApp/target/myApp.ear@shared/log4j-api.jar@META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class
> Caused by: java.lang.IllegalStateException: Can't add different class with 
> same name: org/apache/logging/log4j/util/ProcessIdUtil
> 
> I went through the FAQ and got to know the reason why it occurs.
> 
> Please correct me if I am wrong. I see 2 options:
> 1. To remove those jars from the .ear.
> 2. To exclude those from instrumentation and reporting all together.
> 
> To exclude from instrumentation, i added below to javaagent 
> excludes=<absolute_path>/myApp.ear/shared/log4j-api.jar/META-INF/*
> 
> To exclude from report, I appended the excludes to jacococli.jar command 
> line, as below:
> java -jar <absolute_path>/jacoco-it.exec --classfiles myApp.ear 
> --html=target/html_report 
> --excludes=<absolute_path>/myApp.ear/shared/log4j-api.jar/META-INF/*
> 
> I end up facing the same exception. Is it the correct approach?
> 
> Regards
> Abhay
> 
> 
> 
> On Sunday, December 6, 2020 at 4:58:06 PM UTC+5:30 Marc R. Hoffmann wrote:
> Just provide the *.ear file. JaCoCo traverses archive formats recursively and 
> will find all jars and class files in the ear.
>  
> 
> 
>> On 4. Dec 2020, at 18:46, abhay hegde <[email protected] 
>> <applewebdata://0E4F9E3F-85B3-4DE5-ABFF-DE170DBD737B>> wrote:
>> 
> 
>> Hi Marc,
>> 
>> thank you, for clearing that up! Another question :)
>> 
>> 1. As per JaCoco document,the 
>> --classfiles=<path_to_production_code_jar_file> supports multiple jar files. 
>> Since all my jars are bundled inside the application.ear , how do I provide 
>> those as argument?.
>> 
>> Regards
>> Abhay
>> 
>> 
>> On Fri, Dec 4, 2020 at 12:55 PM Marc Hoffmann <[email protected] 
>> <applewebdata://0E4F9E3F-85B3-4DE5-ABFF-DE170DBD737B>> wrote:
>> Hi Abhay,
>> 
>> this looks like the correct approach. It is always two steps:
>> 
>> 1) Collect execution data on the JVM that runs the production code using the 
>> JaCoCo agent
>> 2) Create coverage report from the exec file(s) from step 1) and the same 
>> class files used in step 1)
>> 
>> Glad to hear that this works for you!
>> 
>> Regards,
>> -marc
>> 
>>> On 4. Dec 2020, at 06:50, Abhay Hegde <[email protected] 
>>> <applewebdata://0E4F9E3F-85B3-4DE5-ABFF-DE170DBD737B>> wrote:
>>> 
>>> I have tried the following, please correct me if I am wrong:
>>> 
>>> 1. export 
>>> JAVA_OPTS=-javaagent:<path_to>/jacocoagent.jar=destfile=<path_to>/jacoco-it.exec
>>> 2. Start JBoss server.
>>> 3. Run the Integration test using maven.
>>> 4. Stop the JBoss server.
>>> 5. Run the command:
>>> java -jar <path_to>/jacococli.jar report <path_to>/jacoco-it.exec 
>>> --classfiles=<path_to_production_code_jar_file> 
>>> --csv=coverage-reports/report_in_csv
>>> Above step will update the jacoco-it.exec with all the instrumented classes.
>>> 6. Coverage report will be present in report_in_csv given in Step 5.  
>>> 
>>> Thanks
>>> Abhay
>>> 
>>> 
>>> On Wednesday, December 2, 2020 at 11:36:04 AM UTC+5:30 Abhay Hegde wrote:
>>> I have an MyApp.ear containing production code and a test.war containing 
>>> end-to-end test code deployed in the same JBoss server on the same host 
>>> machine.
>>> 
>>> MyApp.ear accepts MQ messages and returns the output.
>>> 
>>> test.war sends the MQ messages and asserts the output.
>>> 
>>> Both production and test application is built using maven. I am using 
>>> jacoco 0.8.5 for code coverage. 
>>> 
>>> An end-to-end test is invoked as below in the command line: 
>>> 
>>> $mvn clean verify -DJBOSS_HOME=<path_to_jboss_dir> 
>>> -f=integration-test/pom.xml jacoco:prepare-agent jacoco:report sonar:sonar 
>>> -Dsonar.skip=false -Dit.test=com.mypackage.name.EndToEndTest 
>>> 
>>> 
>>> 
>>> Test execution flow is as below:
>>> 
>>> A test class sends the MQ messages to the MQs that are configured in the 
>>> host.
>>> Production class (MyApp.ear)   listens to the queue and accepts the MQ 
>>> messages for processing.
>>> Processed output is asserted by the test class using Junit.
>>>  Questions:
>>> 
>>> Is it possible to obtain the code coverage of my production classes when i 
>>> run the End to end test ?
>>> If yes, would appreciate if you could point out few key things to be done.
>>> Thanks
>>> Abhay
>>> 
>>> 
>>> 
>>> -- 
>>> 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 [email protected] 
>>> <applewebdata://0E4F9E3F-85B3-4DE5-ABFF-DE170DBD737B>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jacoco/a6311112-d720-41c7-b159-f132e3312e5cn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jacoco/a6311112-d720-41c7-b159-f132e3312e5cn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> 
>> 
>> -- 
>> 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/0QkOV5u1w6Y/unsubscribe 
>> <https://groups.google.com/d/topic/jacoco/0QkOV5u1w6Y/unsubscribe>.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] 
>> <applewebdata://0E4F9E3F-85B3-4DE5-ABFF-DE170DBD737B>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/9B08C031-3069-49A7-96B6-8EBB6F51BFA1%40mountainminds.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/9B08C031-3069-49A7-96B6-8EBB6F51BFA1%40mountainminds.com?utm_medium=email&utm_source=footer>.
>> 
>> 
>> -- 
>> LinkedIN - Abhay Hegde 
>> <https://www.linkedin.com/profile/view?id=112287538&trk=nav_responsive_tab_profile>Contact:-
>>  +91 9000011822 <tel:+91%2090000%2011822>
>> Skype - abhayhegde
>> 
>> -- 
>> 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 [email protected] 
>> <applewebdata://0E4F9E3F-85B3-4DE5-ABFF-DE170DBD737B>.
> 
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/CAHcMQNmhUePRjokay8JZzuwU4AejMTrmVKx8DZuOj_8TPR34Vw%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/CAHcMQNmhUePRjokay8JZzuwU4AejMTrmVKx8DZuOj_8TPR34Vw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/83c5e172-68bd-4d6e-b2e6-a6c6c28c9d78n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jacoco/83c5e172-68bd-4d6e-b2e6-a6c6c28c9d78n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/CD6CBB4B-67FB-4878-8890-C22BE3C4B324%40mountainminds.com.

Reply via email to