• Post Reply Bookmark Topic Watch Topic
  • New Topic

UnMarshalException - Nested ClassNotFoundException

 
Ryan Greenwood
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to rmi. Attempting to run an example out of CoreJava volII. I have followed the steps in the tutorial, however there seems to be a grey area which seems to relate either to class paths, or to class loading??
The source is provided by Cay Horstmann.
The steps are:
1. Compile the source - no packaging
2. rmic -v1.2 the ProductImpl class for stub generation
3. create three directories to test deployment - client, download, server.
4. into server put ProductServer.class, ProductImpl.class, Product.class, ProductImpl_Stub.class
5. into download put ProductImpl_Stub.class, Product.class
6. into client put ProductClient.class, Product.class, client.policy
5. ensure client.policy grants SocketPermission to connect to "*:1024-65535" and "*:8080" (tomcat)
6. move download to webapps directory in tomcat home - presumably this is the directory which tomcat will search to find the specfied resource?
7. start tomcat
8. start new shell and set classpath=
9. start rmiregistry &
10. start new shell and set classpath to the server directory
11. java -Djava.rmi.codebase=http://localhost:8080/download/ ProductServer &
UnMarshalException - nested ClassNotFoundException
 
Randy Motluck
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are running the client and getting the "UnMarshalException - nested ClassNotFoundException ", then you may want to make sure to have the same codebase argument on the java command for the client.
I have gotten around this by making sure the CLASSPATH is set for both the server side and client side. Make sure your basic stuff works before letting RMI fetch needed class definitions.
Then let the full RMI w/ codebase rip!
My 2cents. -Randy
 
Ryan Greenwood
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Randy. Problem is I can't even get the server running, without getting the UnmarshalException etc. The classpath is set to the server classes(which includes the ProductImpl_Stub.class) and the ClassNotFoundException appears to be related to stub classes - ProductImpl_Stub. This leads me to believe that tomcat is not finding the stubs??
 
Grigory Ptashko
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan,

11. java -Djava.rmi.codebase=http://localhost:8080/download/ProductServer &
UnMarshalException - nested ClassNotFoundException

I had the same problem and I fixed it this way: when I was starting my server I noticed that the property which comes with "-D" I mean "java.rmi.server.codebase" (notice that in your post you wrote "java.rmi.codebase" but it must be "java.rmi.server.codebase") was not properly set. I set it in the right way and everything went fine.
So, fisrt of all check that you DO set the property "java.rmi.server.codebase" when starting your server. And the second check whether you set it right to the path (or the URL) where classes reside. I assume that you started rmiregistry in a proper way (with empty $CLASSPATH).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!