perform some operation on your web app so some class coverage can happen.
On Thursday, March 7, 2019 at 9:30:16 AM UTC+5:30, Jitendra Kumar wrote:
>
>
>
> Hi JK,
>
> Edit your setup.sh file as below:
>
> JACOCO_OPTS=" -javaagent:<jacoco
> path>/jacoco/lib/jacocoagent.jar=destfile=<jacoco
> path>/jacoco/jacoco.exec,append=true,includes=a.b.c.d.*"
>
>
>
> CATALINA_OPTS="${CATALINA_OPTS} ${JACOCO_OPTS}"
>
>
> set to Catalina opts not in java opts: why? check below link.
>
>
> "
> https://stackoverflow.com/questions/11222365/catalina-opts-vs-java-opts-what-is-the-difference
> "
>
>
> and do the same thing again and check.
>
>
> -Jitendra
>
>
>
>
> On Thursday, March 7, 2019 at 3:52:13 AM UTC+5:30, jk wrote:
>>
>> One more data point, didn't mention it in my last email. In Jacoce
>> session i don't see the webapp specific packages but generic java packages:
>>
>> This coverage report is based on execution data from the following
>> sessions:
>> Session Start Time Dump Time
>> portal-tb3-9520fd64 Mar 6, 2019 7:13:24 AM Mar 6, 2019 7:13:24 AM
>>
>> Execution data for the following classes is considered in this report:
>> Class Id
>> org.apache.catalina.LifecycleState d852263a2396f00f
>> org.apache.catalina.core.NamingContextListener 452717f152912d7c
>> org.apache.catalina.core.StandardServer a7539e87b0244e61
>> org.apache.catalina.deploy.NamingResourcesImpl 2f3f2a5bb2334e34
>> org.apache.catalina.security.SecurityClassLoad 73724d336975ef8e
>> org.apache.catalina.security.SecurityConfig 20b1920b1c4845b0
>> org.apache.catalina.startup.Bootstrap 761d4791c592d74a
>> org.apache.catalina.startup.Catalina 3f3b3bcb21c7df6e
>> org.apache.catalina.startup.CatalinaProperties 0a403607de81c2b1
>> org.apache.catalina.startup.ClassLoaderFactory 637589ae074b37b0
>> org.apache.catalina.startup.ClassLoaderFactory.2 f884fbe3ffea9504
>> org.apache.catalina.startup.ClassLoaderFactory.Repository
>> 64e04a8157026e9a
>> org.apache.catalina.startup.ClassLoaderFactory.RepositoryType
>> 0512519c8a94741f
>> org.apache.catalina.util.LifecycleBase 462c20e1e81adf7d
>> org.apache.catalina.util.LifecycleMBeanBase 581fb22432fd3a3d
>> org.apache.juli.logging.DirectJDKLog 7ad56dd398c4a76e
>> org.apache.juli.logging.LogFactory d816f6f12317a8e5
>> org.apache.tomcat.util.ExceptionUtils 8f45b5cc6c246f81
>> org.apache.tomcat.util.IntrospectionUtils ad77a79a2458fa82
>> org.apache.tomcat.util.digester.ArrayStack 710ed28fbfdd5d18
>> org.apache.tomcat.util.digester.Digester efdd845ab94fb176
>> org.apache.tomcat.util.digester.Digester.SystemPropertySource
>> bb86c4e6ddcdbb24
>> org.apache.tomcat.util.digester.ObjectCreateRule b3bc8f955478c572
>> org.apache.tomcat.util.digester.Rule 0b92708415dbc6d9
>> org.apache.tomcat.util.digester.RulesBase fa98b7be8cd3adbf
>> org.apache.tomcat.util.digester.SetNextRule 9d43f39c54fbaa21
>> org.apache.tomcat.util.digester.SetPropertiesRule 8a71a46200ae5d2a
>> org.apache.tomcat.util.res.StringManager 7c3e9ecbdd9b53b0
>> org.apache.tomcat.util.res.StringManager.1 44bb08d6a97f529b
>> Thanks,
>> JK
>>
>>
>> On Wed, Mar 6, 2019 at 1:59 PM Konteya Joshi <[email protected]> wrote:
>>
>>> Thanks Jitendra and Evgeny for your input.
>>>
>>> Please find my comments as it will help in answering the questions :
>>> 1) Contents of setup.sh :
>>>
>>> JACOCO_OPTS="-javaagent:/portal/bin/jacoco/lib/jacocoagent.jar=destfile=jacoco.exec,output=file,append=true"
>>> #set JAVA_OPTS=-Dfile.encoding=UTF-8 -Xms256m -Xmx1024m
>>> -XX:PermSize=256m -XX:MaxPermSize=1024m
>>> -javaagent:C:/Install/apache-tomcat-7.0.54/jacoco/jacocoagent.jar=destfile=C:/Install/apache-tomcat-7.0.54/jacoco/ST/jacoco.exec,append=false
>>> #CATALINA_OPTS="${CATALINA_OPTS} ${JACOCO_OPTS}"
>>> JAVA_OPTS="${JAVA_OPTS} ${JACOCO_OPTS}"
>>>
>>> After which i start the ./startup.sh for webserver (which start
>>> catalina.sh). I see the java process started:
>>> root@portal-tb3:/portal/bin# ps -ef|grep java
>>> root 29402 1 87 08:39 pts/0 00:01:17 /usr/bin/java
>>> -Djava.util.logging.config.file=/portal/conf/logging.properties
>>> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
>>> -javaagent:/portal/bin/jacoco/lib/jacocoagent.jar=destfile=jacoco.exec,output=file,append=true
>>>
>>> -Djdk.tls.ephemeralDHKeySize=2048
>>> -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
>>> -Dignore.endorsed.dirs= -classpath
>>> /portal/bin/bootstrap.jar:/portal/bin/tomcat-juli.jar
>>> -Dcatalina.base=/portal -Dcatalina.home=/portal
>>> -Djava.io.tmpdir=/portal/temp org.apache.catalina.startup.Bootstrap start
>>>
>>> Following which i do some browsing on the site
>>> Subsequently shutdown.sh(which calls catalina shutdown)
>>> No matter how many test cases i run i always get the jacoco.exec file of
>>> the same size(which looks suspicious):
>>> *-rw-r----- 1 root root 2086 Mar 6 08:41 jacoco.exec*
>>>
>>> The contents of the jacoce.exec file are cryptice looks like its a
>>> proprietary format , adding a screenshot here:
>>>
>>> [image: Screen Shot 2019-03-06 at 1.51.05 PM.png]
>>>
>>>
>>>
>>> Subsequently i generate the report from the exec file:
>>> java -jar jacoco/lib/jacococli.jar report jacoco.exec --classfiles
>>> /webapps/ROOT/WEB-INF/classes/ --html report
>>>
>>> [INFO] Loading execution data file /portal/bin/jacoco.exec.
>>> [INFO] Analyzing 3394 classes.
>>>
>>> The coverage report has the packages but the coverage is 0%.
>>>
>>> As a troubleshooting i tried to copy the .class files form
>>> /webapps/ROOT/WEB-INF/classes/ to 1 and tried to generate a report from it
>>> , but i see the same results.
>>>
>>> My hunch : Looks like there is some issue in generating the jacoco.exec,
>>> as i see the exec file of the same size 2086 bytes despite of how much
>>> tests i run or even with no tests.
>>>
>>> I would appreciate your help in this issue.
>>>
>>> Thanks,
>>> Konteya.
>>>
>>>
>>>
>>> On Wed, Mar 6, 2019 at 1:38 AM 'Jitendra Kumar' via JaCoCo and EclEmma
>>> Users <[email protected]> wrote:
>>>
>>>> If EXEC file is not proper, in that case, it will always generate 0%
>>>> code coverage for sure.
>>>>
>>>> -Jitendra
>>>>
>>>> On Wednesday, March 6, 2019 at 3:06:10 PM UTC+5:30, Jitendra Kumar
>>>> wrote:
>>>>>
>>>>> According to the command only JACOCO_EXEC_FILE file having an issue,
>>>>> meaning it is not containing proper data or something.
>>>>>
>>>>> -Jitendra
>>>>>
>>>>> On Wednesday, March 6, 2019 at 2:51:51 PM UTC+5:30, Jitendra Kumar
>>>>> wrote:
>>>>>>
>>>>>> Hi JK,
>>>>>>
>>>>>> I need some inputs from you.
>>>>>>
>>>>>> steps:
>>>>>>
>>>>>> 1. Startup your tomcat/container and perform some operations on a web
>>>>>> application so some of the class files consumed by some random operation
>>>>>> like login etc.
>>>>>> 2. Shutdown tomcat gracefully - /<tomcat server dir>/bin/
>>>>>> shutdown.sh/bat etc.
>>>>>> 3. now verify the size of generated jacoco.exec file in your case <
>>>>>> JACOCO_EXEC_FILE>
>>>>>>
>>>>>> Now run "java -jar jacoco/lib/jacococli.jar report JACOCO_EXEC_FILE
>>>>>> --classfiles ~/1/ --html report" command
>>>>>>
>>>>>> some more input like below:
>>>>>>
>>>>>> while running above command what you are getting in the console I
>>>>>> mean how many class files getting consumed.
>>>>>>
>>>>>> [INFO] Loading execution data file JACOCO_EXEC_FILE.
>>>>>> [INFO] Analyzing <????> classes.
>>>>>>
>>>>>> how many class files ?? and if possible share your exec file that
>>>>>> would be great to solve the issue.
>>>>>>
>>>>>> Thanks,
>>>>>> Jitendra
>>>>>>
>>>>>>
>>>>>> On Wednesday, March 6, 2019 at 12:48:16 PM UTC+5:30, jk wrote:
>>>>>>>
>>>>>>> Hi All,
>>>>>>>
>>>>>>> Thanks Jitender and Evgeny!
>>>>>>>
>>>>>>> This is a follow question. Issue i'm seeing is the code coverage for
>>>>>>> all the packages is all 0%
>>>>>>> java -jar jacoco/lib/jacococli.jar report JACOCO_EXEC_FILE
>>>>>>> --classfiles ~/1/ --html report
>>>>>>>
>>>>>>> After which i see the pakage structure created in output directory
>>>>>>> along with index.html and jacoco-session.html. However when i view the
>>>>>>> index.html the coverage is 0% for all
>>>>>>> [image: image.png]
>>>>>>>
>>>>>>>
>>>>>>> Note in the command above ~/1 is the directory where i have copied
>>>>>>> all the .class files. Since i don't which class files are used i copied
>>>>>>> all
>>>>>>> the class files for WEB-INF to 1 as follows:
>>>>>>>
>>>>>>> cd /xxxxxx/webapps/ROOT/WEB-INF/classes/com
>>>>>>>
>>>>>>>
>>>>>>> find . -type f -name "*class" -print0| xargs -0 -I {} cp {} ~/1/
>>>>>>>
>>>>>>> I would appreciate your help.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> JK.
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Mar 4, 2019 at 7:58 AM 'Jitendra Kumar' via JaCoCo and
>>>>>>> EclEmma Users <[email protected]> wrote:
>>>>>>>
>>>>>>>> Hi JK,
>>>>>>>>
>>>>>>>> The answer is YES, but you will not get a meaningful report.
>>>>>>>> Assume in your application you have just accessed login page and
>>>>>>>> assume LoginPage.java is executed, along with that some more java src
>>>>>>>> consumed from LoginPage.java, so once .class files generated you will
>>>>>>>> be
>>>>>>>> able to generate the report without using the java source code of your
>>>>>>>> project but .class & source mapping will not happen meant which code
>>>>>>>> snippet is consumed (green highlighted) and which part is not even
>>>>>>>> accessed
>>>>>>>> or executed means may be dead code (red highlighted).
>>>>>>>>
>>>>>>>> ultimately without the source, you will not be able to find dead
>>>>>>>> code/un accessed code from your source code files for which you are
>>>>>>>> using
>>>>>>>> jacoco.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Jiten
>>>>>>>>
>>>>>>>> On Monday, March 4, 2019 at 8:19:12 PM UTC+5:30, jk wrote:
>>>>>>>>>
>>>>>>>>> Hi Jiten,
>>>>>>>>>
>>>>>>>>> Thanks for your reply.
>>>>>>>>>
>>>>>>>>> One question : sourcefiles parameter is that the location of the
>>>>>>>>> .java files?
>>>>>>>>>
>>>>>>>>> I’m asking as I don’t have the access to the product code. Is it
>>>>>>>>> possible to generate the report for. Just the class files using
>>>>>>>>> —classfiles.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Jk.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sunday, March 3, 2019, 'Jitendra Kumar' via JaCoCo and EclEmma
>>>>>>>>> Users <[email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Hi JK,
>>>>>>>>>>
>>>>>>>>>> pre-requsites:
>>>>>>>>>>
>>>>>>>>>> downloa
>>>>>>>>>>
>>>>>>>>>> *jacoco-0.8.3.zip
>>>>>>>>>> <http://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.3/jacoco-0.8.3.zip>*
>>>>>>>>>>
>>>>>>>>>> *0.8.3 <https://github.com/jacoco/jacoco/tree/v0.8.3>*
>>>>>>>>>>
>>>>>>>>>> 2019/01/23
>>>>>>>>>>
>>>>>>>>>> 3.7 MB
>>>>>>>>>>
>>>>>>>>>> d4f07cb98bbf2305dbd16ee3012d7321
>>>>>>>>>>
>>>>>>>>>> extract and navigate to lib directory, jacococli.jar will be
>>>>>>>>>> there in lib dir.
>>>>>>>>>>
>>>>>>>>>> The most important thing while generating HTML report from the
>>>>>>>>>> *.exec file is providing correct src and class files path so exec
>>>>>>>>>> file can
>>>>>>>>>> map the consumption of code and give you report HTML.
>>>>>>>>>> for that you run like below command:
>>>>>>>>>>
>>>>>>>>>> java -jar <path to jacoco directory>/lib/jacococli.jar report
>>>>>>>>>> <exec file path> --classfiles
>>>>>>>>>> <TOMCAT_HOME>/webapps/dummy/WEB-INF/classes/
>>>>>>>>>> --sourcefiles /opt/dummy/web-inf/classes/ --html /tmp/report
>>>>>>>>>>
>>>>>>>>>> run command like above. you will get html report for sure.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>>
>>>>>>>>>> Jiten
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Monday, March 4, 2019 at 10:51:49 AM UTC+5:30, jk wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi All,
>>>>>>>>>>>
>>>>>>>>>>> I'm a newbie to Jacoco. I needed to perform some code coverage
>>>>>>>>>>> in our webapp. The webapp is shipped as a war file running on
>>>>>>>>>>> tomcat
>>>>>>>>>>> application server. Since I don't have the build information for
>>>>>>>>>>> the webapp
>>>>>>>>>>> as well the source repository for it, the on-fly looked most viable
>>>>>>>>>>> option
>>>>>>>>>>> for me.
>>>>>>>>>>>
>>>>>>>>>>> I have defined the following in setenv.sh file:
>>>>>>>>>>>
>>>>>>>>>>> JACOCO_OPTS="-javaagent:/portal/bin/jacoco/lib/jacocoagent.jar=destfile=JACOCO_EXEC_FILE,output=file,append=false"
>>>>>>>>>>>
>>>>>>>>>>> CATALINA_OPTS="${CATALINA_OPTS} ${JACOCO_OPTS}
>>>>>>>>>>>
>>>>>>>>>>> when i start the webapp i do the file being created when i do
>>>>>>>>>>> browse the site and shutdown catalina.sh i still the file size as 0
>>>>>>>>>>>
>>>>>>>>>>> root@xxx-xxxx:/xxxxxxx/bin# ./shutdown.sh
>>>>>>>>>>> Using CATALINA_BASE: /xxxxxx
>>>>>>>>>>> Using CATALINA_HOME: /xxxxxx
>>>>>>>>>>> Using CATALINA_TMPDIR: /xxxxxx/xxxx
>>>>>>>>>>> Using JRE_HOME: /usr
>>>>>>>>>>> Using CLASSPATH:
>>>>>>>>>>> /xxxxxxx/bin/bootstrap.jar:/portal/bin/tomcat-juli.jar
>>>>>>>>>>> -rw-r----- 1 root root 0 Mar 3 16:07 JACOCO_EXEC_FILE
>>>>>>>>>>> drwxr-x--- 3 root root 4096 Mar 3 16:13 .
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> i'm using the following versions:
>>>>>>>>>>> Server version: Apache Tomcat/8.5.29
>>>>>>>>>>> Server built: Mar 5 2018 13:11:12 UTC
>>>>>>>>>>> Server number: 8.5.29.0
>>>>>>>>>>> OS Name: Linux
>>>>>>>>>>> OS Version: 4.4.0-116-generic
>>>>>>>>>>> Architecture: amd64
>>>>>>>>>>> JVM Version: 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12
>>>>>>>>>>> JVM Vendor: Oracle Corporation
>>>>>>>>>>>
>>>>>>>>>>> The Jacoco version used is :
>>>>>>>>>>> jacoco/0.8.3/jacoco-0.8.3.zip
>>>>>>>>>>> I would appreciate of any insight into how to resolve the issue.
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>> jk
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>> 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/DZNqIGaoPKQ/unsubscribe.
>>>>>>>>>> To unsubscribe from this group and all its topics, send an email
>>>>>>>>>> to [email protected].
>>>>>>>>>> To view this discussion on the web visit
>>>>>>>>>> https://groups.google.com/d/msgid/jacoco/277a9bf5-66a7-4179-a933-a9867a797af9%40googlegroups.com
>>>>>>>>>>
>>>>>>>>>> <https://groups.google.com/d/msgid/jacoco/277a9bf5-66a7-4179-a933-a9867a797af9%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>>> .
>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>
>>>>>>>>> --
>>>>>>>> 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/DZNqIGaoPKQ/unsubscribe.
>>>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>>>> [email protected].
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/jacoco/412e4e3e-08f4-42b2-8823-179a6179b905%40googlegroups.com
>>>>>>>>
>>>>>>>> <https://groups.google.com/d/msgid/jacoco/412e4e3e-08f4-42b2-8823-179a6179b905%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>> --
>>>> 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/f994b6f8-1bbe-413a-8050-c5550065d65c%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/jacoco/f994b6f8-1bbe-413a-8050-c5550065d65c%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
--
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/bf31bd73-cae0-4b89-805d-1536f45332dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.