Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic Class Downloading Simple Question

 
waqas memon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This link will help, let know if you face any problems.
 
waqas memon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic