• Post Reply Bookmark Topic Watch Topic
  • New Topic

RMI: missing _Stub

 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, I was having a tough time getting my RMI working with a test case. Very simple and straightforward. My problem was that when I called Naming.rebind on the server side I got this error

From the error, It seems that it can't find the CalculatorRemote_Stub.class file. However, the Stub is in the same jar file as my 4 other classes I am using.
I did some testing and both my stub and the interface have to be exposed(outside of a jar file in dir structure matching their package). Any idea why java can't pull them out of the jar? I know I have the workaround, but it would make my server side much cleaner to distribute when I get my complex software working with the RMI.
Any one know why this is happening?
Thanks
[ May 21, 2003: Message edited by: Chris Shepherd ]
 
Lin Feng
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you specify your codebase?
I think the remoteException was thrown by the Naming Service. Why you tried to rebind it to the Naming Service, the Naming cannot find the class definition of it.
I am not sure if the Naming Service stub pass the stub class directly or it use MarshalledObject to pass the stub class.
I could be wrong.
Lin
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
if your client has no access to the stubs trough the classpath, then you need
  • have a HTTP server running
  • have the codebase set (to the HTTP server) on the server side (this will make the codebase anotation beeing set when the objects are marshalled -> your client knows where to download the class definition
  • make the required classes available from the HTTP server (check with a browser)


  • if everithing is running on the same machine, then make sure all parts can access the classes:
  • client
  • server
  • rmi registry


  • k
     
    Maulin Vasavada
    Ranch Hand
    Posts: 1873
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hi karl
    i run into the similar issue (it doesnt find CalculatorImp_Stub class) but i'm more puzzled because i seem to follow the convention of running RMI using http codebase. here is my problem,
    i have two servers,
    1. server1
    2. server2
    here is server1's hosting,
    1. the RMI server is on server1.
    2. i have a webserver on server1:8089 (iplanet4)
    3. i have created a directory "rmi" in server1:8089/html/ webaccessible folder.
    4. i have a .java.policy like,
    grant {
    java.security.AllPermissions;
    }; (in /html/rmi folder on the server1)
    here is server2's hosting,
    1. i have put RMI client code on server2
    2. i have a .java.policy like,
    grant {
    java.security.AllPermissions;
    };
    i run RMI server as,
    folder:server1/html/rmi:
    bash$ rmiregistry &
    bash$ java -Djava.rmi.server.codebase=http://server1/html/rmi/ .java.policy CalculatorServer
    i run RMI client as,
    folder:server2/myhome/rmi
    bash$ java -Djava.rmi.server.codebase=http://server1/html/rmi/ -Djava.security.policy=.java.policy CalculatorClient
    i have made sure that http://server1/html/rmi is accessible via the URLConnection from server2's rmi folder (does this imply that URLClassLoader should also find the classes from remote /html/rmi location?). i made sure via making URLConnection to http://server1/html/rmi/CalculatorImpl_Stub.class and just reading bytes opening the input stream.
    the interesting thing is,
    the application runs if i host it on the same sever, meaning server1 and use different folders for the RMI server hosting and the RMI Client hosting (i even tried to move client to my friends home directory and it worked. we didnt have CLASSPATH set then also it worked so i believe it worked via HTTP codebase thing)....
    can you help me?
    regards
    maulin
     
    Maulin Vasavada
    Ranch Hand
    Posts: 1873
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    sorry karl...
    i miswrote my way of running the RMI server...
    i have -Djava.security.policy=.java.policy (in the post i just wrote .java.policy and forgot to write -D property...)
    please show some light...
    regards
    maulin
     
    Ayan Kumar Roy
    Greenhorn
    Posts: 10
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I am also getting the same exception as I am new to RMI technology, I am facing bit difficulty to solve it.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!