问题
I am running tomcat with a jacoco agent like this:
-javaagent:/path_to_jar/jacocoagent.jar=jmx=true,output=tcpclient,port=8001
which I know is working because lsof command lists 88208 TCP localhost:**8001** (LISTEN)
.
When I run this example code with PORT = 8001;
I get the error:
Exception in thread "main" java.net.SocketException: Connection reset
This appears to be an older example from jacoco. Has something changed with that way I need to access the tcp server? I have also tried to access jacoco through their MBeanClient, but it gives me an InstanceNotFoundException and appears that tomcat does not have "org.jacoco:type=Runtime" listed as a bean when I print out all of the domains.
Any suggestions for either option? I just need to be able to get a dump file without stopping the server.
回答1:
Turns out I needed some more java arguments when starting my server:
-Dcom.sun.management.jmxremote.port=9999"
-Dcom.sun.management.jmxremote.ssl=false"
-Dcom.sun.management.jmxremote.authenticate=false"
Without these JMX could not see jacoco as a bean on my localhost.
(this also works for glassfish, but they need to be set using <jvm-options>
)
来源:https://stackoverflow.com/questions/28776124/jacoco-jmx-dump-connection-reset-error