I am getting Cannot bind to URL exception when I am trying to use JMX with Spring. Please suggest.
Code:<<Maven dependency>> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jmx</artifactId> <version>2.0.8</version> </dependency> <<jmxApplication.xml>> <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/> <!-- this bean must not be lazily initialized if the exporting is to happen --> <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"> <property name="beans"> <map> <entry key="bean:name=testBean1" value-ref="testBean"/> </map> </property> <property name="server" ref="mbeanServer"/> <property name="autodetect" value="true"/> <property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/> <property name="notificationListenerMappings"> <map> <entry key="bean:name=testBean1"> <bean class="org.springframework.jmx.ConsoleLoggingNotificationListener"/> </entry> </map> </property> </bean> <bean id="listener" class="org.springframework.jmx.ConsoleLoggingNotificationListener"/> <bean id="testBean" class="org.springframework.jmx.JmxTestBean"> <property name="name" value="TEST"/> <property name="age" value="100"/> </bean> <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean" lazy-init="false"> <property name="objectName" value="connector:name=rmi"/> <property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/myconnector"/> <property name="threaded" value="true"/> <property name="daemon" value="true"/> <property name="server"> <ref local="mbeanServer"/> </property> </bean> <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"> <property name="port" value="1099"/> </bean> </beans> <<Exception>> 2009-11-30 11:20:44,562 ERROR Exception occurred in Thread (id : 21 name : JMX Connector Thread [service:jmx:rmi://localhost/jndi/rmi://localhost:1098/myconnector] ) org.springframework.jmx.JmxException: Could not start JMX connector server after delay; nested exception is java.io.IOException: Cannot bind to URL [rmi://localhost:1098/myconnector]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused: connect] at org.springframework.jmx.support.ConnectorServerFactoryBean$1.run(ConnectorServerFactoryBean.java:157) Caused by: java.io.IOException: Cannot bind to URL [rmi://localhost:1098/myconnector]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused: connect] at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:804) at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:417) at org.springframework.jmx.support.ConnectorServerFactoryBean$1.run(ConnectorServerFactoryBean.java:154) Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused: connect] at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:126) at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:208) at javax.naming.InitialContext.bind(InitialContext.java:400) at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:625) at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:412) ... 1 more Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused: connect at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184) at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322) at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source) at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:120) ... 5 more Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:519) at java.net.Socket.connect(Socket.java:469) at java.net.Socket.<init>(Socket.java:366) at java.net.Socket.<init>(Socket.java:180) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595) ... 10 more


Reply With Quote
