Jacoco instrumenting with weblogic

2,093 views
Skip to first unread message

kanc...@gmail.com

unread,
May 15, 2013, 2:27:12 PM5/15/13
to jac...@googlegroups.com
Hi

I have given the following java option in commandlinf unix, and rather editing the startup.
export JAVA_OPTIONS="$JAVA_OPTIONS -javaagent:/home/../../../jacocoagent.jar=output=tcpserver,port=8030,address=localhost"

This run on a Unix system

My webapplication runs on top of this weblogic server.

Now I need to conduct my testing and generate reports. ( As it's set to listen to port 8030, what type of request should I make to generate report)
How do I get generated report files?


DO I have to use to ant build file? (

ant -Djacocoagent.server.host=<my server> -Djacocoagent.server.port=8030
for this option ant wants to have the class file location in the ant build script?can i give a network path to find the class fiels in web-inf in Unix system? Assuming ant run on another windows machine and work as a clien to make this call?

)
Appreciate your support
Thanks
Kanchana

Marc Hoffmann

unread,
May 16, 2013, 2:25:12 AM5/16/13
to jac...@googlegroups.com
Hi,

please see documentation for the Ant tasts you need to perform the
remote dump and create the report:

http://www.eclemma.org/jacoco/trunk/doc/ant.html#dump
http://www.eclemma.org/jacoco/trunk/doc/ant.html#report

And yes, you need the original class files from your web application
locally on the machine where the report is generated. The report task
will also work on WAR/EAR files. If you want to get source highlighting
in your reports you will also need to supply the Java source files to
the report task.

Best regards,
-marc

kanc...@gmail.com

unread,
May 16, 2013, 9:33:39 AM5/16/13
to jac...@googlegroups.com
On Thursday, May 16, 2013 2:25:12 AM UTC-4, Marc R. Hoffmann wrote:
> Hi, please see documentation for the Ant tasts you need to perform the remote dump and create the report: http://www.eclemma.org/jacoco/trunk/doc/ant.html#dump http://www.eclemma.org/jacoco/trunk/doc/ant.html#report And yes, you need the original class files from your web application locally on the machine where the report is generated. The report task will also work on WAR/EAR files. If you want to get source highlighting in your reports you will also need to supply the Java source files to the report task. Best regards, -marc On 2013-05-15 20:27, kanc...@gmail.com wrote: > Hi > > I have given the following java option in commandlinf unix, and > rather editing the startup. > export JAVA_OPTIONS="$JAVA_OPTIONS > > -javaagent:/home/../../../jacocoagent.jar=output=tcpserver,port=8030,address=localhost" > > This run on a Unix system > > My webapplication runs on top of this weblogic server. > > Now I need to conduct my testing and generate reports. ( As it's set > to listen to port 8030, what type of request should I make to > generate > report) > How do I get generated report files? > > > DO I have to use to ant build file? ( > > ant -Djacocoagent.server.host=<my server> > -Djacocoagent.server.port=8030 > for this option ant wants to have the class file location in the ant > build script?can i give a network path to find the class fiels in > web-inf in Unix system? Assuming ant run on another windows machine > and work as a clien to make this call? > > ) > Appreciate your support > Thanks > Kanchana

Thanks Marc
Got the Ant stuff working. Now my plans are different:). I have weblogic configured sucussefully and jacoco agents runs with no issues to test a webapplication and generate reports as I test through the applicatio. I have given the JAVA_OPTIONS to run
javaagent:/home/../../jacocoagent.jar=output=tcpserver,destfile=jacoco.exec,includes=com.*,dumponexit=true,port=8010,classdumpdir=/../../dump,address=*"
So I see the classdump which Agent scans through and dumps while I navigate through my web application.I would like to have report generatation like I had for my ant tasks and nice details up to method level.
Appreciate your input how to get it done in this set up.
Thanks
Kanchana

Marc Hoffmann

unread,
May 16, 2013, 10:55:29 AM5/16/13
to jac...@googlegroups.com
> I would like to have report generatation like I had
> for my ant tasks and nice details up to method level.

In this case you will need to create the report e.g. with the Ant task
as I described in my previous answer. The agent itself cannot create a
report.

Best regards,
-marc

kanc...@gmail.com

unread,
May 16, 2013, 1:12:45 PM5/16/13
to jac...@googlegroups.com
On Thursday, May 16, 2013 10:55:29 AM UTC-4, Marc R. Hoffmann wrote:
> > I would like to have report generatation like I had > for my ant tasks and nice details up to method level. In this case you will need to create the report e.g. with the Ant task as I described in my previous answer. The agent itself cannot create a report. Best regards, -marc On 2013-05-16 15:33, kanc...@gmail.com wrote: > On Thursday, May 16, 2013 2:25:12 AM UTC-4, Marc R. Hoffmann wrote: >> Hi, please see documentation for the Ant tasts you need to perform >> the remote dump and create the report: >> http://www.eclemma.org/jacoco/trunk/doc/ant.html#dump >> http://www.eclemma.org/jacoco/trunk/doc/ant.html#report And yes, you >> need the original class files from your web application locally on the >> machine where the report is generated. The report task will also work >> on WAR/EAR files. If you want to get source highlighting in your >> reports you will also need to supply the Java source files to the >> report task. Best regards, -marc On 2013-05-15 20:27, >> kanc...@gmail.com wrote: > Hi > > I have given the following java >> option in commandlinf unix, and > rather editing the startup. > export >> JAVA_OPTIONS="$JAVA_OPTIONS > > >> -javaagent:/home/../../../jacocoagent.jar=output=tcpserver,port=8030,address=localhost" >> > > This run on a Unix system > > My webapplication runs on top of >> this weblogic server. > > Now I need to conduct my testing and >> generate reports. ( As it's set > to listen to port 8030, what type of >> request should I make to > generate > report) > How do I get generated >> report files? > > > DO I have to use to ant build file? ( > > ant >> -Djacocoagent.server.host=<my server> > -Djacocoagent.server.port=8030 >> > for this option ant wants to have the class file location in the ant >> > build script?can i give a network path to find the class fiels in > >> web-inf in Unix system? Assuming ant run on another windows machine > >> and work as a clien to make this call? > > ) > Appreciate your support >> > Thanks > Kanchana > > Thanks Marc > Got the Ant stuff working. Now my plans are different:). I have > weblogic configured sucussefully and jacoco agents runs with no > issues > to test a webapplication and generate reports as I test through the > applicatio. I have given the JAVA_OPTIONS to run > > javaagent:/home/../../jacocoagent.jar=output=tcpserver,destfile=jacoco.exec,includes=com.*,dumponexit=true,port=8010,classdumpdir=/../../dump,address=*" > So I see the classdump which Agent scans through and dumps while I > navigate through my web application.I would like to have report > generatation like I had for my ant tasks and nice details up to > method > level. > Appreciate your input how to get it done in this set up. > Thanks > Kanchana

hi Marc,

Appreciate your reply. Please assume that my ant runs on a windows box and and webapp on top of logic runs on a seperate Unix box.
In this case my class files are in the Unix box.
If I'm using jacoco:agent and try to generate reports .. in Ant scripts should I give the network path of the webapp/classes in unix system.Or what if i give the classdumpdir?


<target name="dump" depends="configure">
<echo>Running agent for jacoco results to ${result.exec.file}</echo>
<jacoco:agent property="agentvmparam" address="${jacocoagent.server.host}" port="${jacocoagent.server.port}" destfile="${result.exec.file}" />
</target>

<target name="report">
<jacoco:report>
<executiondata1>
<file file="${result.exec.it.file}" />
</executiondata1>
<structure name="report">
<group name="IT Code Coverage">
<classfiles>
<fileset dir="...................." />
</classfiles>
</group>
</structure>
<html destdir="${result.report.dir}" />
</jacoco:report>
</target>

Marc Hoffmann

unread,
May 17, 2013, 3:34:10 AM5/17/13
to jac...@googlegroups.com
Hi,

as I tried to explain before. You need the classes deployed to your
appserver also for report generation. So why not simply copy the
deployed ear/war to the machine where you generate the report:

<classfiles>
<file file="xxx/myapp.war" />
</classfiles>

JaCoCo will search the archive for class files.

> Or what if i give the classdumpdir?

This is technically possible, but will give you an incomplete report:
You won't see the classes which has not been loaded at all.

Cheers,
-marc

softwaref...@gmail.com

unread,
Jan 7, 2014, 11:18:52 PM1/7/14
to jac...@googlegroups.com, kanc...@gmail.com
Hi, I am using jacoco agent and I would like to take dump on code coverage without having ant dump task which is take dump on VM exit.


I have configured jacocoagent like this below:
-javaagent:/lib/jacocoagent.jar=destfile=/current/jacoco.exec,output=tcpserver,address=ipaddress,port=36003,includes=com.abc.*:com.def.gh.*,dumponexit=true

So, I start my server, jacocoagent is active ...stop my server but no jacoco.exe file is created after shutting down the server

I change output=file in the above jacocoagent, jacoco.exec file is created on shutting down the server but no codecoverge is there.

I dont understand why jacoco.exec is not created while i have output=tcpserver.
I was reading the jacoco documentation. And it says
dumponexit If set to true coverage data will be written on VM shutdown. The dump can only be written if either file is specified or the output is tcpserver/tcpclient and a connection is open at the time when the VM terminates.

What does it mean by connection is open at the time when the VM terminates???

Marc R. Hoffmann

unread,
Jan 8, 2014, 12:47:54 AM1/8/14
to jac...@googlegroups.com
Hi,

exec *files* are only written if output=file. If output=tcpserver this
means you need another process to connect to the specified port and
request a dump. This is possible e.g. with the Ant task or the maven goal.

> What does it mean by connection is open at the time when the VM terminates???

This means that if some dump client has a TCP connection to the JaCoCo
agent at the point in time when the JVM shuts down execution data is
written to that connection. Note that the Ant/Maven dump goals are not
suitable for this as they do a "one shot" dump only and disconnect
afterwards. To get dump on exit over a TCP connection you would need a
special client which stays connected.

But I don't think you need this, as you should have two other options:

1) Use output=false and dumponexit=true and shutdown the server after
you've executed your tests
2) Use output=tcpserver and request a dump with Ant/Maven after you've
executed your tests (no need to shutdown the server for this)

Best regards,
-marc
--
Marc Hoffmann
hoff...@mountainminds.com
_______________________________________________
Mountainminds GmbH & Co. KG

Nussbaumstr. 4 * 80336 Muenchen * Germany
Phone/Fax +49-700-68664637 * 0700-MTNMINDS

Registergericht Muenchen * HRA 80201
Mountainminds Verwaltungs GmbH
Registergericht Muenchen * HRB 143183
Geschaeftsfuehrer Marc Hoffmann


Rajeev A R

unread,
Aug 19, 2015, 4:39:41 AM8/19/15
to JaCoCo and EclEmma Users
Hi Marc,

Can you provide some examples to request for dump using maven when output=tcpserver

Regards
Rajeev

Marc Hoffmann

unread,
Aug 19, 2015, 7:51:26 AM8/19/15
to jac...@googlegroups.com
Hi Rajeev,

there are a couple of possible clients to retrieve execution data:

1) Ant: http://www.eclemma.org/jacoco/trunk/doc/ant.html#dump
2) Maven: http://www.eclemma.org/jacoco/trunk/doc/dump-mojo.html
3) Java API:
http://www.eclemma.org/jacoco/trunk/doc/examples/java/ExecutionDataClient.java
3) Import into Eclipse: http://www.eclemma.org/userdoc/importexport.html

Whatever fits better into your test stack.

Regards,
-marc
>> http://www.eclemma.org/jacoco/trunk/doc/ant.html#dump [1] >>
>> http://www.eclemma.org/jacoco/trunk/doc/ant.html#report [2] And yes,
> --
> 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/b09b9afa-54c4-46cb-a97c-95b219867d1b%40googlegroups.com
> [3].
> For more options, visit https://groups.google.com/d/optout [4].
>
>
> Links:
> ------
> [1] http://www.eclemma.org/jacoco/trunk/doc/ant.html#dump
> [2] http://www.eclemma.org/jacoco/trunk/doc/ant.html#report
> [3]
> https://groups.google.com/d/msgid/jacoco/b09b9afa-54c4-46cb-a97c-95b219867d1b%40googlegroups.com?utm_medium=email&utm_source=footer
> [4] https://groups.google.com/d/optout

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages