Failing to run JMX example

Hi ,

I am trying to run JMX example from http://java.sun.com/j2se/1.5.0/docs/guide/jmx/tutorial/connectors.html

This example contains connection between a server and a client based on RMI.

Part of the code in the server is:

// Create an RMI connector server

//

echo("\nCreate an RMI connector server");

JMXServiceURL url = new JMXServiceURL(

"service:jmx:rmi:///jndi/rmi://localhost:9999/server");

JMXConnectorServer cs =

JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);

// Start the RMI connector server

//

echo("\nStart the RMI connector server");

cs.start();

I am getting exception in the last line...

The exception is:

java.io.IOException: Cannot bind to URL [rmi://localhost:9999/server]: javax.naming.CommunicationException [Root exception is java.rmi.ServerException: Server RemoteException; nested exception is:

java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:

java.lang.ClassNotFoundException: javax.management.remote.rmi.RMIServerImpl_Stub]

at javax.management.remote.rmi.RMIConnectorServer.newIOException(Unknown Source)

at javax.management.remote.rmi.RMIConnectorServer.start(Unknown Source)

at Server.main(Server.java:75)

Caused by: javax.naming.CommunicationException [Root exception is java.rmi.ServerException: Server RemoteException; nested exception is:

java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:

java.lang.ClassNotFoundException: javax.management.remote.rmi.RMIServerImpl_Stub]

at com.sun.jndi.rmi.registry.RegistryContext.bind(Unknown Source)

at com.sun.jndi.toolkit.url.GenericURLContext.bind(Unknown Source)

at javax.naming.InitialContext.bind(Unknown Source)

at javax.management.remote.rmi.RMIConnectorServer.bind(Unknown Source)

... 2 more

Caused by: java.rmi.ServerException: Server RemoteException; nested exception is:

java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:

java.lang.ClassNotFoundException: javax.management.remote.rmi.RMIServerImpl_Stub

at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)

at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)

at sun.rmi.server.UnicastRef.invoke(Unknown Source)

at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)

... 6 more

Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:

java.lang.ClassNotFoundException: javax.management.remote.rmi.RMIServerImpl_Stub

Caused by: java.lang.ClassNotFoundException: javax.management.remote.rmi.RMIServerImpl_Stub

I am running on Windows. It is jdk1.5.0_07 java.

I also added to my classpath the mx4j-rjmx.jar which contains the javax.management.remote.rmi.RMIServerImpl_Stub.

Before starting the server I run the rmiregistry on port 9999 in cmd:

rmiregistry 9999

Then I open another cmd and run there the server class...

As I mentioned before - it fails :(

Can you please give me any idea what am I doing wrong?

Thanks,

Ejik.

[3256 byte] By [Ejika] at [2007-11-22]
# 1
Hi Ejik,Before going into the gory details of how the RMI connector works just verify that the rmiregistry you are running comes from J2SE 5.0 and not an old JDK 1.4.x version.Regards,Luis
lmalventa at 2007-7-14 > top of java,Core,Monitoring & Management...
# 2
Thanks a lot !!!It is working fine since I put the jdk1.5 in the beginning of the path...:)By the way, Ii did not have 1.4 version, but I had different files of rmiregistry in my comp. I guess the wrong one was running...Message was edited by: Ejik
Ejika at 2007-7-14 > top of java,Core,Monitoring & Management...