wood burning stoves 2.0*
The moose likes Distributed Java and the fly likes Dynamic Class Downloading Simple Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Dynamic Class Downloading Simple Question" Watch "Dynamic Class Downloading Simple Question" New topic
Author

Dynamic Class Downloading Simple Question

waqas memon
Greenhorn

Joined: Mar 28, 2008
Posts: 3
I have a Servlet class that binds object to RMI Registry..
And another Servlet that uses Naming.lookup to get that object..
The Server Servlet and Client Servlet for RMI are both different web applications..

I have to do dynamic class downloading at client so that the stubs generated by Server are automatically downloaded at client..

The Manual process of copying stub classes to client works fine, but the need for dynamic downloading arised when the stubs and skeletons were updated at server, while the client had same old stubs.
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

This link will help, let know if you face any problems.


apigee, a better way to API!
waqas memon
Greenhorn

Joined: Mar 28, 2008
Posts: 3
Nitesh, i have read the resource already,
but was not able to compile the client Rmi without stubs or interface.
how can i compile the client?

i.e.
javac does not accept any arguements like -Djava.rmi.codebase="....."
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

waqas:
but was not able to compile the client Rmi without stubs or interface.
how can i compile the client?

javac does not create stubs. So, you do not need to worry about compiling without creating stubs.

waqas: javac does not accept any arguements like -Djava.rmi.codebase="....."

Its not a compile time parameter. You have to pass this parameter while running the server. By the way, the property is java.rmi.server.codebase and not java.rmi.codebase
waqas memon
Greenhorn

Joined: Mar 28, 2008
Posts: 3
oops..
my mistake..
i compiled the client...
now... following steps have been completed.


1. RMI Registry Started with this command.
javaw -classpath %CLASSPATH%; sun.rmi.registry.RegistryImpl

the class path variable is set to..
.;D:\tomcat\common\lib\servlet-api.jar;D:\tomcat\webapps\TestApp\MyStubs\


2. Object binded to RMI Registry.. as follows..
System.setProperty("java.rmi.server.codebase", "http://192.168.0.227:9901/TestApp/MyStubs/")

Naming.rebind("rmi://192.168.0.227:1099/factory", unisonFactory);

3. Compiled the Client


BUT

i can not run the client.... when i run the client it generates an exception,

java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: java.rmi.server.RemoteObjectInvocationHandler
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at RMIClientTest.main(RMIClientTest.java:16)
Caused by: java.lang.ClassNotFoundException: java.rmi.server.RemoteObjectInvocationHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:427)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:161)
at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:631)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:257)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:200)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
... 3 more
 
 
subject: Dynamic Class Downloading Simple Question
 
Similar Threads
Is still required rmic?
RMI Help Needed
unlock Thread
java.rmi.ServerException: java .rmi.UnmarshallException
where's the "sharpen your pencil" answer?