File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Error while registring the server object to RMI registry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error while registring the server object to RMI registry" Watch "Error while registring the server object to RMI registry" New topic
Author

Error while registring the server object to RMI registry

Prakash Chauhan
Greenhorn

Joined: Aug 15, 2006
Posts: 8
Hi all,

One RMI program is giving me following error while registring the server ojbect to the rmi registry.

Can anybody help me out.

---------- New Program run ----------
object instatiatedHelloServer[UnicastServerRef [liveRef: [endpoint:[10.12.46.245:4780](local),objID:[0]]]]
Connection refused to host: 10.12.46.245; nested exception is:
java.net.ConnectException: Connection refused: connect

Thanks in advance.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
Looks like a either a firewall is preventing access to the IP address at the required port or the RMI registry isn't running.


42
Prakash Chauhan
Greenhorn

Joined: Aug 15, 2006
Posts: 8
By keeping firewall turnoff same problem is coming. How do i come to know that RMI registry is not running ? I am registring the server object to the RMI registry using the following method.

Naming.rebind("HelloServer",obj);

Have a look at my program too.

import java.rmi.*;
import java.rmi.server.*;
import java.util.*;

interface HelloInterface extends Remote {
public String sayHello( ) throws RemoteException ;
}

class HelloServer extends UnicastRemoteObject implements HelloInterface{
public HelloServer( ) throws RemoteException {
super( );
}

public String sayHello( ) throws RemoteException {
return "Hello world, the current system time is" +new Date( );
}
}


public class RegisterIt {
public static void main(String [ ] args) {
try
{
HelloServer obj = new HelloServer( );
System.out.println("object instatiated" +obj);
Naming.rebind("HelloServer",obj);
System.out.println("Hello server bound in registry");
}

catch (Exception e)
{
System.out.println(e);
}
}
}
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
if you don't start it (and no other program starts it for you), it's not running.
Prakash Chauhan
Greenhorn

Joined: Aug 15, 2006
Posts: 8
Thanks Jeroen

I got the mistake. I have not opened the rmi registry.

by commpiling all class &
using following command

rmic HelloServer
start rmiregistry
java RegisterIt
java HelloClient

I am getting the result. Thanks once again.
 
jQuery in Action, 2nd edition
 
subject: Error while registring the server object to RMI registry