need suggestions regarding jacoco authentication

35 views
Skip to first unread message

sudheer kumar

unread,
Dec 26, 2024, 12:53:52 PM12/26/24
to JaCoCo and EclEmma Users
Hi All,

We recently started doing POC on functional/automation testing code coverage tools and want to use Jacoco for our Java Apps. 

The problem we are facing using dump command without authentication. Our devops teams are not ready to open the tcp ports on the app server, so we can run the dump commands over tcp.

I read through the Jacoco docs and other questions and I understand Jacoco does not provide any authentication functionality. 

Before i start solutioning, I want to hear different thoughts and suggestions from the team.

Please guide.

Thanks,
Sudheer

Evgeny Mandrikov

unread,
Dec 26, 2024, 1:13:19 PM12/26/24
to jac...@googlegroups.com
Hi,

you can connect via JMX - see “jmx” parameter of JaCoCo agent, for JMX AFAIK you can enable authentication 

Regards,
Evgeny



--
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 visit https://groups.google.com/d/msgid/jacoco/c06eb363-63c2-4242-8127-53e3a3052ddcn%40googlegroups.com.

sudheer kumar

unread,
Dec 30, 2024, 1:12:00 PM12/30/24
to JaCoCo and EclEmma Users
Thank you for your response. 

I am new to this. Can you give me more insights on how to use jmx. 

So i start the application with the jacocoagent as below

java -javaagent:/path/to/jacoco-agent.jar=jmx=true,output=tcpserver,address=*,port=<port_number> -jar <your_application>.jar

how do i pass credentials for jmx in above ?? so i can use the same credentials when using jmx client to dump the coverage

sudheer kumar

unread,
Dec 30, 2024, 8:06:18 PM12/30/24
to JaCoCo and EclEmma Users
to add more details, where do we put the  jmxremote.password file and how do the jacocoagent reference it

sudheer kumar

unread,
Dec 30, 2024, 8:15:51 PM12/30/24
to JaCoCo and EclEmma Users
I am not sure if i am doing it right or not...

java -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=c:\coverage\sample\jmxremote.password -Dcom.sun.management.jmxremote.access.file=c:\coverage\sample\jmxremote.access -javaagent:C:\tools\jacoco\lib\jacocoagent.jar=jmx=true,output=tcpserver,address=*,port=6300 -jar C:\coverage\sample\calculator.jar

this is how instrumented my jar file with jmx

now the app works fine...

the problem is... still i am able to use "dump"  without authentication..

java -jar c:/tools/jacoco/lib/jacococli.jar dump --address localhost --port 6300 --destfile C:/coverage/assurenxt/exec/jacoco.exec

the jacoco.exec file is created. i donot want this command to work when jmx=true. is my understanding wrong? 

Evgeny Mandrikov

unread,
Dec 31, 2024, 4:20:54 AM12/31/24
to jac...@googlegroups.com
On Tue, 31 Dec 2024 at 02:15, sudheer kumar <sudhe...@gmail.com> wrote:
I am not sure if i am doing it right or not...

java -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=c:\coverage\sample\jmxremote.password -Dcom.sun.management.jmxremote.access.file=c:\coverage\sample\jmxremote.access -javaagent:C:\tools\jacoco\lib\jacocoagent.jar=jmx=true,output=tcpserver,address=*,port=6300 -jar C:\coverage\sample\calculator.jar

this is how instrumented my jar file with jmx

now the app works fine...

the problem is... still i am able to use "dump"  without authentication..

java -jar c:/tools/jacoco/lib/jacococli.jar dump --address localhost --port 6300 --destfile C:/coverage/assurenxt/exec/jacoco.exec

the jacoco.exec file is created. i donot want this command to work when jmx=true. is my understanding wrong? 


To make data available only via JMX use
output=none
instead of
output=tcpserver,address=*,port=6300


Regards,
Evgeny

sudheer kumar

unread,
Jan 4, 2025, 12:29:38 AMJan 4
to JaCoCo and EclEmma Users
Thank you so much for your suggestion. it worked.

java -javaagent:C:\tools\jacoco\lib\jacocoagent.jar=jmx=true,output=none -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.port=1090 -Dcom.sun.management.jmxremote.rmi.port=1099 -Dcom.sun.management.jmxremote.password.file=c:\coverage\sample\jmxremote.password -Dcom.sun.management.jmxremote.access.file=c:\coverage\sample\jmxremote.access -Dcom.sun.management.jmxremote.ssl=true  -jar C:\coverage\sample\calculator.jar

then i used jconsole to connect to see if it works, no luck.

i used the https://github.com/jacoco/jacoco/blob/35f352a95551f532da9013f3587e2591cdcef6ec/org.jacoco.examples/src/org/jacoco/examples/MBeanClient.java#L53 this code. but no luck. 

What should be service url?? i am using service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi as the service url

I get the below exception

Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.NoSuchObjectException: no such object in table]

i do not see any docs on how to implement using jmx. 

any guidance is highly appreciated.

Reply all
Reply to author
Forward
0 new messages