LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-21-2005, 01:46 AM   #1
sumeetmaithil
LQ Newbie
 
Registered: Sep 2005
Posts: 2

Rep: Reputation: 0
RMI Connection fail


Hi
I am new in JAVA RMI. I am running my RMI code in red hat linux. I am using the same linux machine for both client and server. While starting the Server I am getting this error:
# Java AddServer &

Exception: java.rmi.RemoteException: connection failed to host: ; nested exception is:

Code is like this:
1) AddServerIntf that extends the Remote Class

import java.rmi.*;
public interface AddServerIntf extends Remote{
double add(double d1, double d2) throws RemoteException;
}

2) AddServerImpl that define the method in AddServerIntf

import java.rmi.*;
import java.rmi.server.*;
public class AddServerImpl extends UnicastRemoteObject implements AddServerIntf {
public AddServerImpl() throws RemoteException { }
public double add(double d1, double d2) throws RemoteException {
return d1+d2;
}
}

3) The AddServer class that bind the Server name:

import java.rmi.*;
import java.net.*;
public class AddServer {
public static void main(String args[]) {
try{
System.setSecurityManager(new RMISecurityManager());
AddServerImpl addServerImpl = new AddServerImpl();
Naming.rebind("AddServer", addServerImpl);
}

catch(Exception e){
System.out.println("Exception: " +e);

}
}
}

4) The AddClient class :

import java.rmi.*;
public class AddClient {
public static void main(String args[])
{
try{
String addServerURL = "rmi://" + args[0] + "/AddServer";
AddServerIntf addServerIntf = (AddServerIntf)Naming.lookup(addServerURL);
System.out.println("The First no. is: " + args[1]);
double d1 = Double.valueOf(args[1]).doubleValue();
System.out.println("The second no. is: " + args[2]);
double d2 = Double.valueOf(args[2]).doubleValue();
System.out.println("The sum is: " +addServerIntf.add(d1,d2));
}
catch(Exception e){
System.out.println("Exception: " +e);
}
}
}

I had generated bot stub and Skeleton classes in same directory.

Any Help would be Appreciated

sumeet
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java RMI Connection Problem mtest Programming 7 09-01-2005 02:43 PM
[RMI JOnAS] RMI or IPTABLES Configuration fred2210 Programming 2 04-14-2005 12:24 AM
Fail to accept connection PoorGuy Programming 7 11-04-2004 09:10 AM
jmx rmi connection csfalcon Programming 2 06-24-2004 09:40 AM
Will select fail if connection couldn't be established? ruchika Linux - Software 0 09-10-2003 11:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration