Ok - I managed to come back to this today and have another look and found the solution... not sure I understand why this isn't better documented....
The Spring recommended way of getting the mbean server:
Code:
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean" />
won't return you the jvm mbean factory - annoyingly, so when you try to bind to the same rmi registry later you can't as it is read-only.
The solution is simply to use the ManagmentFactory that is part of 1.5:
Code:
<bean id="mbeanServer" class="java.lang.management.ManagementFactory" factory-method="getPlatformMBeanServer"/>
This returns you the one exposed by the jvm so you can skip the whole section regarding configuring your rmi registry i.e. this part...
Code:
<bean id="registry"
class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
<property name="port" value="4446" />
</bean>
<bean id="serverConnector"
class="org.springframework.jmx.support.ConnectorServerFactoryBean" destroy-method="destroy">
<property name="objectName" value="connector:name=rmi" />
<property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:4446/servername" />
<property name="server" ref="mbeanServer"/>
</bean>
...and just do the jmx exporter (org.springframework.jmx.export.MBeanExporter) stuff required to push you beans onto the platform server!
Remeber, to expose the jvm mbeans you need to start up the jvm with the following (or similar, this is the simplest but no security):
Code:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=4446
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
and it all works - fantastic!