jmx connection problem
cyrillk May 25, 2012 9:01 AMHi,
try to connect to infinispan JMX statistics programmatically. JMX statistics is enabled and I can connect to it with jconsole easily if I use process PID. Otherwise, if I try to connect using URI I face with some problems. I try to connect to it using spring framework.
globalJmxStatistics.enabled=true
globalJmxStatistics.jmxDomain=jmx
so, if I use such connection string
<bean id="searchConnector" class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
<property name="serviceUrl" value="service:jmx:rmi:///jndi/rmi://localhost:9898/jmx" />
</bean>
I get such type of exception.
Caused by: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: jmx
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.connect(MBeanServerConnectionFactoryBean.java:131)
at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.afterPropertiesSet(MBeanServerConnectionFactoryBean.java:119)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 12 more
Caused by: javax.naming.NameNotFoundException: jmx
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:99)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:255)
... 17 more
I tried default "infinispan" & "org.infinispan" with the same result.
If connection looks like "service:jmx:rmi:///jndi/rmi://localhost:9898" than exception like this
Caused by: java.lang.ClassCastException: com.sun.jndi.rmi.registry.RegistryContext cannot be cast to javax.management.remote.rmi.RMIServer
at javax.management.remote.rmi.RMIConnector.narrowJRMPServer(RMIConnector.java:1897)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1892)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:255)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.connect(MBeanServerConnectionFactoryBean.java:131)
at org.springframework.jmx.support.MBeanServerConnectionFactoryBean.afterPropertiesSet(MBeanServerConnectionFactoryBean.java:119)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 12 more
It seems for me that I need to know proper connection name to connect to infinispan statistics, but can't find it.