| Version 3 (modified by nigel.sim, 9 months ago) |
|---|
Starting JMX for Tomcat under Maven
As I run most of my development webservers using Maven's Tomcat plugin, I also need to have the JMX service running so I can develop the MBeans. Attempts to simply put the -D commands on the Maven command line failed, but putting them in the MAVEN_OPTS variable worked, so:
export MAVEN_OPTS="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=18080 -Dcom.sun.management.jmxremote.authenticate=false -Djava.net.preferIPv4Stack=true"
MAVEN_OPTS="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=18080 -Dcom.sun.management.jmxremote.authenticate=false -Djava.net.preferIPv4Stack=true" mvn -Dmaven.tomcat.port=8180 tomcat:run
A related issue was that I could only connect to the JMX using JConsole from the machine running the JMX server, despite the port being open, and me being able to telnet to it. The issue is that the server reports it's IP address back to the client, so if your hosts file returns 127.0.0.1 when resolving your host name, you are in trouble. Try adding:
-Djava.rmi.server.hostname=xxx.xxx.xxx.xxx
