Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NotBoundException on clientside related to Naming.lookup

 
Diego Bowen
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello computer folks,
I've been tring to get this RMI helloworld up and running on two different machines without much success. Here is a link to the source code I've been using: http://www.umsl.edu/~siegel/course302/part3/RMI/RMI-simple.html
On the client side:
java -Djava.rmi.server.codebase=http://(serversIPaddress)/~DBowen/myRMI/
-Djava.security.policy=java.policy HelloMain
HelloApplet exception:~DBowen/myRMI/HelloServer
java.rmi.NotBoundException: ~DBowen/myRmi/HelloServer
............
at HelloMain.main(HelloMain.java 12)
here is line 12:
Hello obj = (Hello)Naming.lookup("http://theserverIP/~DBowen/myRMI/HelloServer");
I've tried various variations within the (...)
such as "//theServerIp/..."
"rmi://theSeverIP/"
All with the same results. Can someone give me a hand please???
Thanks in advance.
 
Chris De Vries
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You definitely should get rid of the "http:" in the Naming.lookup() method argument. What you are doing with the Naming.lookup() method is querying the RMI registry for a remote reference to an object on the server. RMI does this using the RMI protocol, so adding an "rmi:" instead of "http:" is correct, but not necessary.
You should use the same url in the lookup as you used in the Naming.rebind() call of HelloImpl, plus the server name if it was not included in the rebind call. I typically do not include the server name in the rebind call for two reasons:
  • As a security feature you can only call Naming.rebind() to bind an object to a registry running on the same machine.
  • If you move the code onto a new server, you do not have to rewrite that portion of the code.

  • Naming.lookup() definitely needs the server name to be included so it can find the machine with the UnicastRemoteObject it needs to use.
    I know this answer is confusing, and many people explain this better than I can. Try the RMI trail of Sun's java tutorial if you need more help.
    Chris
     
    Diego Bowen
    Ranch Hand
    Posts: 50
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hello Chris, thanks for the post...I figured out those changes and implemented them...And I was able to get the server up and running, I even checked the registry and I have "//linux:1099/~DBowen/myRMI/HelloServer" in it. However when I rn the following on the client I get the following maessae:
    java -Djava.rmi.server.codebase=httP://192.0.3.17/~DBowen/myRMI -Djava.security.policy=java.policy HelloMain
    HelloApplet exception:error unmarshalling return; nested exception is:
    java.lang.classNotfoundException: HelloImpl_Stub

    I'm really really frustrated with RMI. so can some pleaase help me...thanks
     
    Chris De Vries
    Ranch Hand
    Posts: 65
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Diego Bowen:
    ... I was able to get the server up and running, I even checked the registry and I have "//linux:1099/~DBowen/myRMI/HelloServer" in it. However when I rn the following on the client I get the following maessae:
    java -Djava.rmi.server.codebase=httP://192.0.3.17/~DBowen/myRMI -Djava.security.policy=java.policy HelloMain
    HelloApplet exception:error unmarshalling return; nested exception is:
    java.lang.classNotfoundException: HelloImpl_Stub

    Do you have a regular http server running on port 80, and is "~DBowen" mapped to a directory in which you have a "myRMI" subdirectory with the file "HelloImpl_Stub.class" in it? Both the rmiregistry and the web server must be available for dynamic classloading using the hypertext transfer protocol.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic