J
Jan Diederich
Hi,
also with the official Examples by Sun and MX4J I can't start any JMX server
after the JSR _160_ Standard. I get always the notification: "Connection
refused".
I have no Software-Fireware installed and the Enterprise-Firewall should
only protect the net to the outworld.
The StackTrace print is IIRC at Sun and MX4J the same.
(This example is by MX4J)
P.S: A Server over MX4J after JSR _77_ (and maybe older) works.
Only after JSR 160 it wount run.
Der Code:
JMXServiceURL address = null;
try {
// The address of the connector server
address = new JMXServiceURL("service:jmx:rmi://rmiHost/jndi/jndiPath");
} catch (Exception e) {
echo("Invalid URL");
e.printStackTrace();
}
try {
// The MBeanServer to which the JMXConnectorServer will be attached to
JustAnotherBean tmpBean = new JustAnotherBean();
MBeanServer server = MBeanServerFactory.createMBeanServer();
server.registerMBean(tmpBean, new ObjectName(
"TempBeans:name=JustAnotherBean"));
// Code example that uses the JNDI short form specifying JNDI properties
via environment Map
// The JNDI environment
Map environment = new HashMap();
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.rmi.registry.RegistryContextFactory");
environment.put(Context.PROVIDER_URL, "rmi://localhost:1099");
// Create the JMXCconnectorServer
cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(
address, environment, server);
// Start the JMXConnectorServer
cntorServer.start();
} catch (Exception e) {
e.printStackTrace();
}
Der StackTrace Print:
java.io.IOException: Cannot bind to URL [jndiPath]:
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(Unknown
Source)
at javax.management.remote.rmi.RMIConnectorServer.start(Unknown Source)
at justBean.TestServer.<init>(TestServer.java:106)
at justBean.TestServer.main(TestServer.java:122)
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(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.bind(Unknown Source)
at javax.naming.InitialContext.bind(Unknown Source)
at javax.management.remote.rmi.RMIConnectorServer.bind(Unknown Source)
.... 3 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(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
.... 7 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown
Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown
Source)
.... 12 more
also with the official Examples by Sun and MX4J I can't start any JMX server
after the JSR _160_ Standard. I get always the notification: "Connection
refused".
I have no Software-Fireware installed and the Enterprise-Firewall should
only protect the net to the outworld.
The StackTrace print is IIRC at Sun and MX4J the same.
(This example is by MX4J)
P.S: A Server over MX4J after JSR _77_ (and maybe older) works.
Only after JSR 160 it wount run.
Der Code:
JMXServiceURL address = null;
try {
// The address of the connector server
address = new JMXServiceURL("service:jmx:rmi://rmiHost/jndi/jndiPath");
} catch (Exception e) {
echo("Invalid URL");
e.printStackTrace();
}
try {
// The MBeanServer to which the JMXConnectorServer will be attached to
JustAnotherBean tmpBean = new JustAnotherBean();
MBeanServer server = MBeanServerFactory.createMBeanServer();
server.registerMBean(tmpBean, new ObjectName(
"TempBeans:name=JustAnotherBean"));
// Code example that uses the JNDI short form specifying JNDI properties
via environment Map
// The JNDI environment
Map environment = new HashMap();
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.rmi.registry.RegistryContextFactory");
environment.put(Context.PROVIDER_URL, "rmi://localhost:1099");
// Create the JMXCconnectorServer
cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(
address, environment, server);
// Start the JMXConnectorServer
cntorServer.start();
} catch (Exception e) {
e.printStackTrace();
}
Der StackTrace Print:
java.io.IOException: Cannot bind to URL [jndiPath]:
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(Unknown
Source)
at javax.management.remote.rmi.RMIConnectorServer.start(Unknown Source)
at justBean.TestServer.<init>(TestServer.java:106)
at justBean.TestServer.main(TestServer.java:122)
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(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.bind(Unknown Source)
at javax.naming.InitialContext.bind(Unknown Source)
at javax.management.remote.rmi.RMIConnectorServer.bind(Unknown Source)
.... 3 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(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
.... 7 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown
Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown
Source)
.... 12 more