This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why am I getting java.rmi.NotBoundException exception on localhost rmi test.

 
Jo Jake
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Java as well as rmi. While running a test code I end up with exceptions and couldn't make it work. All I had is just a hello message from server. I get the java.rmi.NotBoundException when I call Naming.lookup I tried with different values for lookup url such as rmi://127.0.0.1/serviceA, rmi://localhost/serviceA etc ..but nothing did worked for me. Anyone please could help me to get this working.

Here is my server code :





And this server code compiles and runs without any issues.

Client code :



The client code compiles without any issues, and on running give the following :
The stack trace of exception :

java.rmi.NotBoundException: serviceA
at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:134)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:101)
at rmiclient.main(rmiclient.java:16)
Exception in thread "main" java.lang.NullPointerException
at rmiclient.main(rmiclient.java:21)



Thanks for any effort, probably many might have experienced the same I hope.
 
Jo Jake
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody who have worked in RMI here to help me ?
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's hard to look at someones code and figure out what is wrong. It's like looking at a misspelled word.

Probable you haven't exported the remote object. The following is from a test program I use.



Now you bind/rebind the object "cb".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic