wood burning stoves 2.0*
The moose likes Distributed Java and the fly likes Running RMIRegistry using servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Running RMIRegistry using servlet" Watch "Running RMIRegistry using servlet" New topic
Author

Running RMIRegistry using servlet

n tank
Greenhorn

Joined: Mar 28, 2002
Posts: 1
Hi,
I'm trying to run RMIRegistry using servlet, after I start it, I'm trying to run another application from command line and trying to bind an object in the RMIRegistry.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I'm getting following exception on the application side:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: abc.xyz.aaaImpl_Stub(no security manager: RMI class loader disabled)
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: abc.xyz.aaaImpl_Stub(no security manager: RMI class loader disabled)
java.lang.ClassNotFoundException: abc.xyz.aaaImpl_Stub(no security manager: RMI class loader disabled)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:354)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at abc.xyz.bbb.register(Unknown Source)
at abc.xyz.bbb.main(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at abc.xyz.ccc.main(Unknown Source)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
On servlet side (where I'm running RMIRegistry)
I have java.rmi.server.logCalls & sun.rmi.server.exceptionTrace turned on and I'm getting:
sun.rmi.registry.RegistryImpl[0:0:0, 0]: void bind(java.lang.String, java.rmi.Remote)]
exception: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: abc.xyz.aaaImpl_Stub(no security manager: RMI class loader disabled)
java.lang.ClassNotFoundException
: abc.xyz.aaaImpl_Stub(no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:318)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:132)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:143)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:918)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:319)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:187)
at sun.rmi.transport.Transport$1.run(Transport.java:152)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
at java.lang.Thread.run(Thread.java:484)
Exception dispatching call to [0:0:0, 0] in thread "RMI TCP Connection(3)-10.128.201.7" at Tue Jun 04 16:37:39 EDT 2002:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: abc.xyz.aaaImpl_Stub(no security manager: RMI class loader disabled)
java.lang.ClassNotFoundException: abc.xyz.aaaImpl_Stub (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:318)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:132)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:143)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:918)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:319)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:187)
at sun.rmi.transport.Transport$1.run(Transport.java:152)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
at java.lang.Thread.run(Thread.java:484)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I have set up java.rmi.server.codebase property appropriately on the servlet side.
This set up works for me correctly If I set up the classpath of my tomcat before starting tomcat. I don't think I need to setup classpath, java.rmi.server.codebase should work, but, somehow I'm missing something.
ANY help with this is greatly appriciated.
Thank you
Junaid Bhatra
Ranch Hand

Joined: Jun 27, 2000
Posts: 213
This problem is occuring because on your servlet side (where you are running the rmiregistry), there is no SecurityManager installed. Hence the RMIClassLoader refuses to download code dynamically (in this case the stubs, since you are doing a bind()). This problem would not occur if the stubs themselves are located in the rmiregistry's classpath (no dynamic downloading would occur).
Start Tomcat with a security manager, (java -Djava.security.manager ....). You probably would also need to specify a policy file, with the appropriate permissions, since the security manager by default, restricts the user code (i.e. your servlet) from doing pretty much everything.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running RMIRegistry using servlet