File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:Stub class not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:Stub class not found" Watch "NX:Stub class not found" New topic
Author

NX:Stub class not found

guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
I write a interface DBAccess which extends Remote
and a class DBAccessImpl which implements DBAccess
At last I write a test class Named Server
String hostName ;
try{
LocateRegistry.createRegistry(1099);
DBAccessImpl DBAccess = new DBAccessImpl();
hostName = "localhost";
Naming.rebind("//localhost:1099/DBAccess",DBAccess);
System.out.println("DBAccess rebind");

}
....
when i run . i get these error message like:
java.rmi.StubNotFoundException: Stub class not found: DBAccessImpl_Stub; nested
exception is:
java.lang.ClassNotFoundException: DBAccessImpl_Stub
at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:98)
at sun.rmi.server.RemoteProxy.getStub(RemoteProxy.java:55).....
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11424
    
  85

Hi Gy,
Did you run the RMI Compiler (rmic) against your compiled classes?
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
But in the document which I download from sun:
You must not require the use of an HTTP server.
You must not require the installation of a security manager.
You must provide all classes pre-installed so that no dynamic class downloading occurs.
You must use RMI over JRMP (do not use IIOP)
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11424
    
  85

Hi Gy,
The RMI Compiler is seperate to everything you mentioned.
The RMI Compiler will create the skeleton and stub files for you (actually the skeleton files are not necessary, and you can switch off their creation).
The requirement You must provide all classes pre-installed so that no dynamic class downloading occurs. requires you to bundle the stub files that are created by the RMI Compiler into your jar files.
You said that you wrote a class DBAccessImpl which implements DBAccess - does this class also extend UnicastRemoteObject?
Regards, Andrew
guyue0505
Greenhorn

Joined: May 25, 2003
Posts: 21
first thanks you very much.
(the DBAccessImpl extends UnicastRemoteObject of course.)
Second , i run "rmic -d . DBAccessImpl"
and then I write a test class named Client,
and i run Client. it's does Ok
but my question is :
Do i must run "rmic -d ...." before run the server
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11424
    
  85

Hi Gy,
Do i must run "rmic -d ...." before run the server
rmic is a compiler, so you must run it at least once after each time your remote code (DBAccessImpl) changes. It will then create the code necessary to handle RMI, compile it, and delete it.
You can then run the server as many times as you like without doing another recompile.
Regards, Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX:Stub class not found