I have deployed a jacoco-server which listens on serversocket and then generate report.
Here is the code for creating serversocket
public static void main(final String[] args) throws IOException {
ApplicationContext context = SpringApplication.run(CodeCoverageApplication.class, args);
final ServerSocket server = new ServerSocket(PORT, 0);
log.info("Jacoco Server started");
while (true) {
log.info("Initiating handler...");
Socket clientSocket = server.accept(); // Accept the incoming connection
// Retrieve CodeCoverageHandler bean from the Spring context
CodeCoverageHandler codeCoverageHandler = context.getBean(CodeCoverageHandler.class);
// Set the socket for this instance
codeCoverageHandler.setSocket(clientSocket);
// Start the handler in a new thread
new Thread(codeCoverageHandler).start();
log.info("Started new handler");
}
}
I am trying to attach jacoco-agent in service under test by passing this argument in JVM OPTIONS as -javaagent:/usr/local/jacoco-agent.jar=address=jacoco-server, port=6300
Note:- ALB is attached with jacoco-server to handle requests
But I am not able to attach the agent in the service. I am getting below error in the logs. Please hlep
Error:-
java.io.IOException: Invalid execution data file.
at org.jacoco.agent.rt.internal_43f5073.core.data.ExecutionDataReader.read(ExecutionDataReader.java:90)
at org.jacoco.agent.rt.internal_43f5073.output.TcpConnection.run(TcpConnection.java:60)
at org.jacoco.agent.rt.internal_43f5073.output.TcpClientOutput$1.run(TcpClientOutput.java:56)
at java.base/java.lang.Thread.run(Thread.java:834)
jacoc-version: 0.8.5
Thanks & Regards,
Rajeev Nandan