Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX:Stub class not found

 
guyue0505
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gy,
Did you run the RMI Compiler (rmic) against your compiled classes?
Regards, Andrew
 
guyue0505
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic