aspose file tools*
The moose likes Distributed Java and the fly likes Very New to RMI - Help plz - question on NotBoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Very New to RMI - Help plz - question on NotBoundException" Watch "Very New to RMI - Help plz - question on NotBoundException" New topic
Author

Very New to RMI - Help plz - question on NotBoundException

S Thanigaivel
Ranch Hand

Joined: Oct 06, 2005
Posts: 60
This is my first RMI program, and i am running this in a same machine and i'm using jdk 1.5

file name : MethodImpl.java
-----------------------------------
import java.rmi.*;

interface MethodImpl extends Remote
{
double getSqrt(double dbl) throws RemoteException;
}

____________________________________________________

file name : RMIServer.java
----------------------------------------------------------
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;

public class RMIServer extends UnicastRemoteObject implements MethodImpl
{
public RMIServer() throws RemoteException {}
{
System.out.println("The server is instantiated");
}

public double getSqrt(double dbl)
{
return Math.sqrt(dbl);
}

public static void main(String[] args)
{
try
{
RMIServer server = new RMIServer();

Naming.rebind("sqrt",server);
}
catch(Exception ex)
{
System.out.println("Error -- "+ex.toString());
}
}
}
___________________________________________________________

file name : RMIClient.java
--------------------------------------------------------
import java.rmi.*;
import java.rmi.registry.*;

public class RMIClient
{
public static void main(String[] args){
try
{
MethodImpl mthdImpl = (MethodImpl)Naming.lookup("rmi://127.0.0.1/sqrt");
double dbl = mthdImpl.getSqrt(100);
System.out.println("SQRT:"+dbl);
}
catch(Exception ex)
{
System.out.println("Error -- "+ex.toString());
}
}
}
___________________________________________________________

I compiled the above like

javac MethodImpl.java
javac RMIServer.java
javac RMIClient.java

and as a result i got

MethodImpl.class
RMIServer.class
RMIClient.class

then i used rmic compiler to create stub and skeleton like

rmic RMIServer

above action generated only the

RMIServer_stub.class and it doesn't create RMIServer_skeleton.class

but there is no error message.

What may be the problem?
How to create skeleton?



Please help me out
-------------------------------------------------------

Thanks in Advance

Thanigaivel S.

[ October 12, 2005: Message edited by: S Thanigaivel ]

[ October 12, 2005: Message edited by: S Thanigaivel ]
[ October 12, 2005: Message edited by: S Thanigaivel ]
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

There is no longer a _skeleton class. (since way back 1.3? or 1.2)


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
S Thanigaivel
Ranch Hand

Joined: Oct 06, 2005
Posts: 60
Thank you, Mr.Edward Harned
-------------------

now, i'm facing a different problem

i compile the RMIServer using rmic compiler as
>rmic RMIServer

then after RMIServer_Stub.class got created

i executed the following cmd

>start rmiregistry

A new blank command prompt window opened

then as i opened another cmd prompt window and executed the RMIClient class file i'm getting the following error

java.rmi.NotBoundException: sqrt

above error was thrown by the following line
MethodImpl mthdImpl = (MethodImpl)Naming.lookup("rmi://127.0.0.1/sqrt");

please help me to clear this error

_________________

Regards,
Thanigaivel
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You need to run the programs in this order -

1.) RMI registry - provides the registry to bind the server to, and that the client looks up the server in.

2.) Server - server starts and binds itself to registry.

3.) Client - client looks up server in registry and gets a reference to the server.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
S Thanigaivel
Ranch Hand

Joined: Oct 06, 2005
Posts: 60
Thanks for your help!

Now I cleared my exceptions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Very New to RMI - Help plz - question on NotBoundException