Jacoco :Dump Connection refused error

75 views
Skip to first unread message

Aman Singh Tomar

unread,
Sep 25, 2023, 3:48:56 AM9/25/23
to JaCoCo and EclEmma Users
Hi Developers,

Can you please assist me on the below Jacoco maven plugin issue;

I am getting connection refused error during jacoco:dump goal.

Below is my pom file :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>jacoco</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>jacoco</name>
<description>jacoco</description>
<properties>
<java.version>17</java.version>
<jacoco.agent.argLine>-javaagent:/Users/tomara/.m2/repository/org/jacoco/org.jacoco.agent/0.8.10/org.jacoco.agent-0.8.10-runtime.jar=destfile=/Users/tomara/Documents/git/jacoco/target/jacoco.exec</jacoco.agent.argLine>
<jacoco.propertyName>coverageAgent</jacoco.propertyName>
<jacoco.destFile>${project.build.directory}/coverage.exec</jacoco.destFile>
<jacoco.append>false</jacoco.append>
<!-- <jacoco.exclClassLoaders>sun.reflect.DelegatingClassLoader:MyClassLoader</jacoco.exclClassLoaders>-->
<!-- <jacoco.inclBootstrapClasses>true</jacoco.inclBootstrapClasses>-->
<!-- <jacoco.inclNoLocationClasses>true</jacoco.inclNoLocationClasses>-->
<!-- <jacoco.sessionId>session</jacoco.sessionId>-->
<jacoco.dumpOnExit>true</jacoco.dumpOnExit>
<jacoco.output>file</jacoco.output>
<jacoco.address>localhost</jacoco.address>
<jacoco.port>36320</jacoco.port>
<jacoco.classDumpDir>${project.build.directory}/classdumps</jacoco.classDumpDir>
<!-- <jacoco.jmx>true</jacoco.jmx>-->

<jacoco.dataFile>${jacoco.destFile}</jacoco.dataFile>


</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.5</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>9.5</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>9.5</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
<version>9.5</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>9.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jacoco/org.jacoco.cli -->
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.cli</artifactId>
<version>0.8.10</version>
</dependency>

</dependencies>

<build>
<plugins>
<!-- Configure Surefire plugin for unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version> <!-- Use a version compatible with JaCoCo 0.8.10 -->
<configuration>
<argLine> ${coverageAgent}</argLine>
</configuration>
</plugin>

<!-- Configure Failsafe plugin for integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0</version> <!-- Use a version compatible with JaCoCo 0.8.10 -->
<configuration>
<argLine> ${coverageAgent}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
<goal>dump</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>




</project>

 And Below is the maven error :-

 --- jacoco-maven-plugin:0.8.8:dump (default) @ jacoco ---
[DEBUG] Loading mojo org.jacoco:jacoco-maven-plugin:0.8.8:dump from plugin realm ClassRealm[plugin>org.jacoco:jacoco-maven-plugin:0.8.8, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@531d72ca]
[DEBUG] Configuring mojo execution 'org.jacoco:jacoco-maven-plugin:0.8.8:dump:default' with basic configurator -->
[DEBUG]   (f) address = localhost
[DEBUG]   (f) append = false
[DEBUG]   (f) destFile = /Users/tomara/Documents/git/jacoco/target/coverage.exec
[DEBUG]   (f) dump = true
[DEBUG]   (f) port = 36320
[DEBUG]   (f) project = MavenProject: com.example:jacoco:0.0.1-SNAPSHOT @ /Users/tomara/Documents/git/jacoco/pom.xml
[DEBUG]   (f) reset = false
[DEBUG]   (f) retryCount = 10
[DEBUG]   (f) skip = false
[DEBUG] -- end configuration --
[INFO] Connecting to localhost/127.0.0.1:36320
[INFO] Connection refused
[INFO] Connecting to localhost/127.0.0.1:36320
[INFO] Connection refused
[INFO] Connecting to localhost/127.0.0.1:36320
[INFO] Connection refused
[INFO] Connecting to localhost/127.0.0.1:36320
[INFO] Connection refused
[INFO] Connecting to localhost/127.0.0.1:36320
[INFO] Connection refused


Please help mates.... Not able to understand why this is happening

Marc Hoffmann

unread,
Sep 25, 2023, 4:31:14 AM9/25/23
to jac...@googlegroups.com
Hi,

this simply means there is no JaCoCo agent running on localhost port 36320 at the point in time when you try to generate the dump.

With linux tools like netstat -a you can get a list of all ports which are currently bound.

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/6f96a049-153c-48bb-b418-cee6b4cb02c3n%40googlegroups.com.

Aman Singh Tomar

unread,
Sep 25, 2023, 6:19:14 AM9/25/23
to JaCoCo and EclEmma Users
Hi,

Thanks for replying...

Can you please help me to identify why this jacoco agent is not running ?
Am I missing something in configuration of jacoco ? or Do I need to attach it to some lifecycle phase ?
Or what exactly do I need to do in order to make it work ?

I am been struggling many weeks to figure out this.

Thanks in advance.

Aman Singh Tomar

unread,
Sep 25, 2023, 6:55:45 AM9/25/23
to JaCoCo and EclEmma Users
Hi Marc, 
Can you please suggest what shall I do to make it work ?

Marc Hoffmann

unread,
Sep 25, 2023, 12:26:53 PM9/25/23
to jac...@googlegroups.com
Hi Aman,

why do you think you need the dump goal? It is for advanced use cases only..

JaCoCo documentation comes with a basic, working example. I would recommend to start from there: https://www.jacoco.org/jacoco/trunk/doc/

Regards,
-marc

Aman Singh Tomar

unread,
Sep 25, 2023, 12:39:44 PM9/25/23
to JaCoCo and EclEmma Users
Hi Marc,

So we are using this dump goal in CI. 
So earlier we were working on jdk 8 but when we migrated to jdk 17, this goal started failing.

so I am been struggling to find the root cause and to fix this .

Not sure what exactly is breaking it.

Thanks & Regards

Marc Hoffmann

unread,
Sep 25, 2023, 12:43:54 PM9/25/23
to jac...@googlegroups.com
Hi Aman,

in this case you have to analyse the process under test. I would start with the following questions:

1) What exactly is the command line? Is the JaCoCo agent properly configured here?
2) Are there any log messages on stderr when the process starts?
3) Is the process under test still running when you execute the dump goal?

Regards,
-marc




Message has been deleted

Aman Singh Tomar

unread,
Sep 25, 2023, 11:10:29 PM9/25/23
to JaCoCo and EclEmma Users
Hi Marc,

Answering to your questions below :
1. What exactly is the command line? Is the JaCoCo agent properly configured here? -> In the command line agent is getting set but it is not coming up. 
2. Are there any log messages on stderr when the process starts? - No logs or anything related to it.
3. Is the process under test still running when you execute the dump goal? - No process is running during dump goal.

Not sure what exactly is happening or am  I missing.

I just wanted to create a simple maven project which will execute single JUnit classes and it is produce jacoco.exec and also execute jacoco:dump goal.

Maybe you have some working project then I will look into that too.

Thanks and Regards

Marc Hoffmann

unread,
Sep 26, 2023, 6:22:26 AM9/26/23
to JaCoCo and EclEmma Users
Hi Aman,

3. Is the process under test still running when you execute the dump goal? - No process is running during dump goal.

In this case the dump goal will not be able to connect. The dump tool is for advanced use cases only where the application under test is e.g. a long running server process.


I just wanted to create a simple maven project which will execute single JUnit classes and it is produce jacoco.exec and also execute jacoco:dump goal.

Then why do you want to use the dump goal? The standard behaviour of the JaCoCo agent is to write execution data to disc when the test JVM terminates.

Please see documentation which also includes such a simple example.

Regards,
-marc


Aman Singh Tomar

unread,
Sep 27, 2023, 4:29:42 AM9/27/23
to JaCoCo and EclEmma Users
Hi Marc,

Can we have a short call to discuss this issue in much detail ? 
It would be very helpful if we could connect and discuss this..

I am ok with your time.

Thanks

Marc Hoffmann

unread,
Sep 29, 2023, 7:10:12 AM9/29/23
to JaCoCo and EclEmma Users
Unfortunately we cannot provide private support.

As said before please read our documentation and start with the simple, working examples which we provide.

Regards,
-marc

Reply all
Reply to author
Forward
Message has been deleted
0 new messages