Elaborating on the solution I identified using the links and pointers anttix
gave me in his answer.
So, as mentioned in the answer above, using the system properties com.sun.management.jmxremote.port
and com.sun.management.jmxremote.rmi.port
is the basis for the solution.
I changed my Spring config to remove the registry
and serverConnector
beans, as this was not allowing me to register port 1099
(PermissionExceptions
resulted in my being unable to bind to port 1099
), and used the platform mbean server.
The Spring config I used was just this:
<bean id="mbeanServer" class="java.lang.management.ManagementFactory" factory-method="getPlatformMBeanServer"/>
Then, I started the application using the following switches:
-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=w.x.y.z -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
Setting the java.rmi.server.hostname
to the NAT VIP w.x.y.z
is critical as we need to be able to execute remote operations on locally created remote objects from outwith the network.
Note: This solution will only work on Java 7u4 or higher.