Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

RMI UnmarshalException when starting RMI server -  RSS feed

 
Brian Yingling
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I'm trying to start up a RMI server and I keep getting the following
message:
Error: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: edu.nyu.rmi.MathWhizzImpl_Stub

MathWhizzImpl_Stub is clearly within the edu/nyu/rmi directory.
Here are the following files I'm using:
MathWhizzClient.class
MathWhizzServer.class
MathWhizzImpl.class
MathWhizzImpl_Stub.class (created using rmic)
MathWhizzInterface.class
Mathwhizz.jar (this resides in a directory called 'lib' -- and yes, the 'w'
is lowercase here)
My directory structure looks like this:
bin\edu\nyu\rmi - all of the .class files reside here
src - all of the .java files reside here - I compile and dump .class files
into bin
lib - the Mathwhizz.jar file resides here
There is clearly a MathWhizzImpl_Stub.class file in this directory.
I suspect its the way I'm setting up my classpaths but I just can't
see the issue. Anyone have any ideas (By the way, I've used an
implementation class (MathWhizzImpl.class) instead of having the Server class extend UnicastRemoteObject).
These are the processes I go through on how I (try to) implement RMI
1. I compile the implentation class using rmic (I know at the very
least it can find the edu/nyu/rmi directory because it creates the
MathWhizzImpl_Stub.class there:
rmic -v1.2 -d bin -classpath .;bin;lib;lib\Mathwhizz.jar edu.nyu.rmi.MathWhizzImpl
---
2. Next, I start the rmiregistry:
start rmiregistry
---
3. I now start the server
java -classpath .;bin;lib\Mathwhizz.jar -Djava.security.policy=lib\all.policy edu.nyu.rmi.MathWhizzServer
Now, when I type this in, I get an error message of the following:...
"Error: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: edu.nyu.rmi.MathWhizzImpl_Stub"
Any thoughts on what I'm doing wrong?
 
Jason Kingsley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think (I could be wrong but this is buzzing in my head) that this kind of error can happen if you start the rmiregistry from the same directory as your project - ie, the classfiles are reachable by the rmiregistry prog.
So try starting rmiregistry from a different dir without a classpath etc...
cheers
 
Suat Ugurlu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I had exactly the same problem in w2k and solved it by changing
path and classpath system variables.
If you update them to show where your classes are, it will be ok.
you can ensure if your changes take effect by typing
"set classpath" and "set path" commands at command prompt.
Regards,Suat
 
Sanjaya Balasuriya
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya, guys.
Thanks to you all replied to the initial question.
I also got the same problem and got resolved by using your comments.
From one command prompt set the class path to the direcory where your classes are.
Then from the same prompt start rmiregistry.
Then from another prompt start your application.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Setting the classpath for rmiregistry will most probably work, but you can run into problems with it. The recommended way of fixing the problem your having is to *unset* the classpath that rmiregistry runs under, and specify the codebase for your server component. This way you don't run into possible class collisions. It's pretty technical but you can read all about it in the Sun Documentation for RMI.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could start your registry from inside your server startup code if you are only running a single server on the machine. Just use:

Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!