File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sun's RMI tutorial fails for me

 
Kevin Stembridge
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm new to RMI and thought I'd start with Sun's RMI tutorial that comes with the documentation download in jdk1.5.

I am following this tutorial word for word, even using their supplied source code without modification and I get a ClassNotFoundException when running the Server class. The beginning of the stack trace is pasted below.

This is the link to the tutorial that I'm following:
JDK 1.5 RMI Tutorial

To save you looking it up, this is the source code that is failing. The exception is thrown from the following line:

registry.bind("Hello", stub);



I'm running jdk1.5.0_02 on a linux machine.

Partial Stack trace:
Server exception: java.rmi.ServerException: RemoteEx ception occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep tion is:
java.lang.ClassNotFoundException: example.hello.Hello
java.rmi.ServerException: RemoteException occurred in server thread; nested exce ption is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep tion is:
java.lang.ClassNotFoundException: example.hello.Hello
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:385 )
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4 60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport .java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream RemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java: 223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:343)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at example.hello.Server.main(Server.java:24)
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you need to set the java.rmi.server.codebase property when you run your server. This property tells remote JVMs where to get class files from when they get a remote reference that they don't have a class file for. The RMI registry is itself a remote Java program running in another JVM, so when you try to bind, it's going to fail because it doesn't have a reference to your class files. The command line to start the server should look something like this -

 
Kevin Stembridge
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nate,
That worked perfectly! Runs without any trouble now.

Cheers,
Kevin
 
anshu veda
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey I am facing a similar problem.
Actually the jdk1.5 specs
[http://java.sun.com/j2se/1.5.0/docs/guide/rmi/hello/hello-world.html#51]
specify clearlythat codebase is needed to be specified only if pre1.5 JVM clients need to be supported, which is not the case here.

SO why the jvm is not able to find classes and program not running.

I dunno actually my whole thing was working initially where i had Mandrake with jdk installed using rpm, but i just got debian installed and installed jdk from bin package where the same code has stopped running.


Pls help ..
 
bhaskara navuluri
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

this is regarding your failure vth the RMI on Linux platform

When using RMI u need to set some platform specific properties. for example on windows u need to set system.properties.
in the same way u just search for similar properties files on your Linux platform(I am not sure which properties file you will be using i Linux Platform )

all the best and good luck

bye and good luck


bhas

[ EJFH: Remove invitation to take it offline. We don't do that here. ]
[ July 25, 2005: Message edited by: Ernest Friedman-Hill ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic