aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes SCJD RMI Practice 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 "SCJD RMI Practice" Watch "SCJD RMI Practice" New topic
Author

SCJD RMI Practice

Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

Hi people,

I'm practicing some RMI concepts on a pc (lets call it pc A) a simple Hello World test for my SCJD. It works fine. The problem is when i try to start the client from another pc (pc B).

Steps on pc A (server):
-----------------------
I compile the server object, client object and interface.
I create the stub file using >rmic ServerImpl
I start the registry with >start rmiregistry.
I start the server.

note: in the client object i have the following:

HelloInterface server = (HelloInterface)Naming.lookup("rmi://192.168.0.3:1099/Server");

the ip address is the LAN ip of the server.

Steps on pc B (client):
-----------------------
Copy the generated client.class file from the server to the client (pc B).
I run the client and it says it cannot find HelloInterface (which is on the server (pc A).

note: the server is run with JRE 1.4 and the client runs with JRE 1.5.

Where am i going wrong?

Thanks in advance and regards,
Marzo.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

Live life to an interface, not an implementation!
Matthew Baranowski
Greenhorn

Joined: Aug 22, 2005
Posts: 5
I am working through my SCJD as well. I found there can be a lot of small gotchas. To start with, are you copying all the class files to the new server? And don't forget the stub files.

Matt


SCJP
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

All of the files are on the server, even the client, but then i copy the client.class file and put it in the client pc (pc B acording to my example) and try to run it.

Am i doing it the right way?

I'm getting the following error:

NoClassDefFoundError: InterfaceFile

It's like it can't find the remote interface file (or it can't find the stub over the LAN).

Thanks in advance,
Marzo.
hatim osman
Ranch Hand

Joined: Jun 10, 2005
Posts: 105
Hi...
did you copy Your Remote interface (your compiled .class extention of the Remote interface that acts as the contract between the client and the server) and the stub file generated by rmic utility into PC B?
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

Actually no, i didn't. Must i?
Matthew Baranowski
Greenhorn

Joined: Aug 22, 2005
Posts: 5
Could you post the actual error? I expect that it is telling you that it cannot find the stub class.
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

The error i was first getting when i started the client was the folowing:

NoClassDefFoundError: interfaceFile

So then i copied both the compiled client.class file and the interface.class file to the client.

But now i get i security error. Client machine has JRE 1.5 and server has 1.4.

Any ideas?
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

I'm not getting the security error any more because i copied the interface file AND the stub file to my client machine, now it runs like acharm.

Thanks and best regards,
Marzo.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCJD RMI Practice
 
Similar Threads
Why my RMI connection throw exceptions?
How to read Clients CPU information on Server
Am i missing something here?
Problems with Java RMI
how to get Clients CPU information on Server using Java RMI