Fix JMX RMI port configuration

Set the following ports in java command line:

com.sun.management.jmxremote.port
com.sun.management.jmxremote.rmi.port

Example on unique port 9229:

-Djava.net.preferIPv4Stack=true 
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9229 
-Dcom.sun.management.jmxremote.rmi.port=9229
-Djava.rmi.server.hostname=190.57.138.218 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false

In Tomcat / TomEE set them in bin/setenv.sh file:

export CATALINA_OPTS="$CATALINA_OPTS -server -Xmx6000m -Xms512m -XX:MaxPermSize=400m -Djava.net.preferIPv4Stack=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9229 -Dcom.sun.management.jmxremote.rmi.port=9229 -Djava.rmi.server.hostname=190.57.138.218 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

export JAVA_OPTS="-client -Xms8m -Xmx128m -XX:MaxPermSize=64m -Djava.net.preferIPv4Stack=true"

Due to a bug this doesnt works in java versions <= 1.7.0_51. Please upgrade the java/JDK version.

Resources:

http://stackoverflow.com/questions/20884353/why-java-opens-3-ports-when-jmx-is-configured/21552812#21552812

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s