• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI problem

 
chun liu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm new here, probably this question has been published before.
I have generated Server.jar and trying to start RMI server, but keep getting exception
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: suncertify.server.RMIServer_Stub
but I have made sure suncertify.server.RMIServer_Stub is in Server.jar
I also tried to set codebase, didn't help
I didn't install any SecurityManager
Thank you for your helps
 
Javini Javono
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm new to RMI, but here is a go at your question
only because I've seen that error "a million times."
I strongly recommend Core Java, Volume II--Advanced Features
by Horstmann and Cornell, as it walks you through the
intricacies of RMI using a "trivial" beginner's example, which
is very helpful.
The error you mention probably is class path related, .jar file
related, or both. If you are in Windows, I recommend going
into your System control panel, and deleting the CLASSPATH
variable, that way "you are clean." If you are on a UNIX based
system, such as Mac OS X, when your terminal comes up, make
sure you are not setting your class path.
If you work "clean" in this way, RMI, which is extremely fussy,
is less apt to be confused. Hope this little bit of advice helps.
Others with more experience than I may have better explanations.
Thanks,
Javini Javono
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chun,
Originally posted by chun liu:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: suncertify.server.RMIServer_Stub
but I have made sure suncertify.server.RMIServer_Stub is in Server.jar
I also tried to set codebase, didn't help
I didn't install any SecurityManager

Run the following command on your Server.jar:
java vtf Server.jar > output
Then:
more output
and make sure that it contains an entry for:
suncertify/server/RMIServer_Stub.class
The directory structure is significant, so it's not enough that the stub file be present it must have the same directory prefix as the other class files in the suncertify/server directory.
For instance, if you had jar'ed the RMIServer_Stub.class, rather than the suncertify/server/RMIServer_Stub.class, when the JRE looks for suncertify.server.RMIServer_Stub in the Server.jar file it won't find it.
Also, I don't think the problem is related to not having a Security Manager. If you check your assignment instructions I think you'll see that you are prohibited from using a security manager.
Hope this helps,
George
[ January 25, 2004: Message edited by: George Marinkovich ]
 
Javini Javono
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
George refreshed my memory as to where I had seen that error so many times
(though I still may have seen it due to class path issues, so I still recommend
not using class paths, though I am just an RMI beginner).
For my initial RMI learning experiences, I created an rmi1 package.
Using cd (change directory), position yourself just outside of the
rmi1 folder. The you can issue the following commands to compile things correctly.

where GenImpl is the ...Impl class for which I need the stub: GenImpl_Stub.class.
Once you get the above, then you can place it into a .jar file:

I haven't tried running this elementary test system as a .jar executable,
but that's how it gets set up. [Though just now I did test it:
java -jar rmi1/app.jar &
in Mac OS X based unix, and the trivial server ran fine.]
Thanks,
Javini Javono
 
chun liu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies. But I have checked my classpath and I'm sure Server.jar is in my classpath. And I also tried the George's suggestion -- unjar the Server.jar and made sure stub class is in right place. I tried to use JBuilder to build and start the server, and also tried to use Ant script to build and start server in command line. I got the exact same error. I think I'm sure it's not classpath problem in my case? I'm very confused. Please help. Thanka
 
chun liu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Just for those of you who are also have the same problem:
I solved this problem by not only putting Server.jar into classpath when start rmi server, but also putting Server.jar into classpath when when start rmiregistry so that rmiregistry can find the stub. I'm not quite clear why it works this way though. I thought rmiregistry is just a naming/look up service. It shouldn't care about classpath
 
Javini Javono
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Perhaps keep in mind that it might be better not to use any class paths
since the Sun examiner might not be using any.
My suggestion given above, I believe, will work even if other applications
and Java IDE's have set your class path for you. If you compile and build
outside of the IDE using line commands (and .bat or .sh files or ant)
to build, the above advice will definitely work, and your result will
be portable to any machine, including the Sun examiner's.
Thanks,
Javini Javono
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic