Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while registring the server object to RMI registry

 
Prakash Chauhan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like a either a firewall is preventing access to the IP address at the required port or the RMI registry isn't running.
 
Prakash Chauhan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you don't start it (and no other program starts it for you), it's not running.
 
Prakash Chauhan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic