oggiemc
asked on
java rmi connection exception
Hi all,
Im getting the following connection exception when i try to run a java RMI client class:
java.rmi.ConnectException: Connection refused to host: 195.162.2.1.; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPE ndpoint.ne wSocket(TC PEndpoint. java:601)
at sun.rmi.transport.tcp.TCPC hannel.cre ateConnect ion(TCPCha nnel.java: 198)
at sun.rmi.transport.tcp.TCPC hannel.new Connection (TCPChanne l.java:184 )
at sun.rmi.server.UnicastRef. invoke(Uni castRef.ja va:110)
at java.rmi.server.RemoteObje ctInvocati onHandler. invokeRemo teMethod(R emoteObjec tInvocatio nHandler.j ava:178)
at java.rmi.server.RemoteObje ctInvocati onHandler. invoke(Rem oteObjectI nvocationH andler.jav a:132)
at $Proxy0.getNextCashierNum( Unknown Source)
at AuctionClient.<init>(Aucti onClient.j ava:36)
at AuctionClient.main(Auction Client.jav a:77)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.s ocketConne ct(Native Method)
at java.net.PlainSocketImpl.d oConnect(P lainSocket Impl.java: 333)
at java.net.PlainSocketImpl.c onnectToAd dress(Plai nSocketImp l.java:195 )
at java.net.PlainSocketImpl.c onnect(Pla inSocketIm pl.java:18 2)
at java.net.SocksSocketImpl.c onnect(Soc ksSocketIm pl.java:36 6)
at java.net.Socket.connect(So cket.java: 525)
at java.net.Socket.connect(So cket.java: 475)
at java.net.Socket.<init>(Soc ket.java:3 72)
at java.net.Socket.<init>(Soc ket.java:1 86)
at sun.rmi.transport.proxy.RM IDirectSoc ketFactory .createSoc ket(RMIDir ectSocketF actory.jav a:22)
at sun.rmi.transport.proxy.RM IMasterSoc ketFactory .createSoc ket(RMIMas terSocketF actory.jav a:128)
at sun.rmi.transport.tcp.TCPE ndpoint.ne wSocket(TC PEndpoint. java:595)
Ive included the client class..
Can someone help me out here please
Thanks in advance
Im getting the following connection exception when i try to run a java RMI client class:
java.rmi.ConnectException:
java.net.ConnectException:
at sun.rmi.transport.tcp.TCPE
at sun.rmi.transport.tcp.TCPC
at sun.rmi.transport.tcp.TCPC
at sun.rmi.server.UnicastRef.
at java.rmi.server.RemoteObje
at java.rmi.server.RemoteObje
at $Proxy0.getNextCashierNum(
at AuctionClient.<init>(Aucti
at AuctionClient.main(Auction
Caused by: java.net.ConnectException:
at java.net.PlainSocketImpl.s
at java.net.PlainSocketImpl.d
at java.net.PlainSocketImpl.c
at java.net.PlainSocketImpl.c
at java.net.SocksSocketImpl.c
at java.net.Socket.connect(So
at java.net.Socket.connect(So
at java.net.Socket.<init>(Soc
at java.net.Socket.<init>(Soc
at sun.rmi.transport.proxy.RM
at sun.rmi.transport.proxy.RM
at sun.rmi.transport.tcp.TCPE
Ive included the client class..
Can someone help me out here please
Thanks in advance
// imports for GUI
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
// imports for RMI
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
public class AuctionClient extends JFrame
{
private DataControl dc;
private JTabbedPane jTabbedPane = null;
private JPanel jContentPane = null;
private Container container;
private FlowLayout layout;
private int cashierNumber;
public AuctionClient (DataControl dcParm)
{
super ("Auction Interface");
// set up data
dc = dcParm;
// dc.readBidders ("Bidders.csv");
// dc.readItems ("Items.csv");
try{
cashierNumber = dc.getNextCashierNum();
} catch (Exception e)
{ e.printStackTrace(); }
layout = new FlowLayout();
// get content pane and set its layout
container = getContentPane();
container.setLayout( layout );
jTabbedPane = new JTabbedPane();
//jTabbedPane.add("Users", getJUsersPane());
//jTabbedPane.add("Items", getJItemsPane());
jTabbedPane.add("Bids", new BidPanel(dc));
jTabbedPane.add("Check Out", new CheckOutPanel(dc, cashierNumber));
container.add (jTabbedPane);
setSize( 700, 500 );
setVisible( true );
}
public static void main( String args[] )
{
try
{
String hostName;
InputStreamReader is =
new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(is);
System.out.println(
"Enter the RMIRegistry host namer:");
hostName = br.readLine();
DataControl dc = (DataControl) Naming.lookup(
"rmi://" + hostName + "/AuctionServer");
AuctionClient application = new AuctionClient(dc);
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
catch (MalformedURLException murle)
{
System.out.println();
System.out.println( "MalformedURLException");
System.out.println(murle);
}
catch (RemoteException re)
{
System.out.println();
System.out.println( "RemoteException");
System.out.println(re);
}
catch (NotBoundException nbe)
{
System.out.println();
System.out.println( "NotBoundException");
System.out.println(nbe);
}
catch (Exception e)
{
System.out.println();
System.out.println( "Exception");
System.out.println(e);
}
}
}
Make sure the service is running at the right address and port
Also make sure that you are not behind a firewall. You have to bypass the proxy in this case.
ASKER
Valeri, I havent had problems running servlets with apache tomcat so should this be an issue?
cehj, the ip address is my local machine and im using the RMI default port (1099)
cehj, the ip address is my local machine and im using the RMI default port (1099)
>>cehj, the ip address is my local machine and im using the RMI default port (1099)
That may be so. That's a different question to whether it's running
That may be so. That's a different question to whether it's running
ASKER
cehj, not too sure what you mean..The registry is running on port 1099
Assuming Windows, please post the output of
netstat -n -p tcp
ASKER
please see attached file
netstat.docx
netstat.docx
That shows rmi running on a quite different address
ASKER
Ok, Im new to this.What am i suppose to be looking at here? From what i can see, under local address i see my IP address followed by port number 1099 and under foreign address, my IP followed by port number 55526..What is the foreign address referencing / what am i suppose to be looking for? Any explanation would be much appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, i changed the address and still getting the same error:
java.rmi.ConnectException Connection refused to host: 192.168.1.1; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPE ndpoint.ne wSocket(TC PEndpoint. java:601)
at sun.rmi.transport.tcp.TCPC hannel.cre ateConnect ion(TCPCha nnel.java: 198)
at sun.rmi.transport.tcp.TCPC hannel.new Connection (TCPChanne l.java:184 )
at sun.rmi.server.UnicastRef. invoke(Uni castRef.ja va:110)
at java.rmi.server.RemoteObje ctInvocati onHandler. invokeRemo teMethod(R emoteObjec tInvocatio nHandler.j ava:178)
at java.rmi.server.RemoteObje ctInvocati onHandler. invoke(Rem oteObjectI nvocationH andler.jav a:132)
at $Proxy0.getNextCashierNum( Unknown Source)
at AuctionClient.<init>(Aucti onClient.j ava:36)
at AuctionClient.main(Auction Client.jav a:77)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.s ocketConne ct(Native Method)
at java.net.PlainSocketImpl.d oConnect(P lainSocket Impl.java: 333)
at java.net.PlainSocketImpl.c onnectToAd dress(Plai nSocketImp l.java:195 )
at java.net.PlainSocketImpl.c onnect(Pla inSocketIm pl.java:18 2)
at java.net.SocksSocketImpl.c onnect(Soc ksSocketIm pl.java:36 6)
at java.net.Socket.connect(So cket.java: 525)
at java.net.Socket.connect(So cket.java: 475)
at java.net.Socket.<init>(Soc ket.java:3 72)
at java.net.Socket.<init>(Soc ket.java:1 86)
at sun.rmi.transport.proxy.RM IDirectSoc ketFactory .createSoc ket(RMIDir ectSocketF actory.jav a:22)
at sun.rmi.transport.proxy.RM IMasterSoc ketFactory .createSoc ket(RMIMas terSocketF actory.jav a:128)
at sun.rmi.transport.tcp.TCPE ndpoint.ne wSocket(TC PEndpoint. java:595)
... 8 more
java.rmi.ConnectException Connection refused to host: 192.168.1.1; nested exception is:
java.net.ConnectException:
at sun.rmi.transport.tcp.TCPE
at sun.rmi.transport.tcp.TCPC
at sun.rmi.transport.tcp.TCPC
at sun.rmi.server.UnicastRef.
at java.rmi.server.RemoteObje
at java.rmi.server.RemoteObje
at $Proxy0.getNextCashierNum(
at AuctionClient.<init>(Aucti
at AuctionClient.main(Auction
Caused by: java.net.ConnectException:
at java.net.PlainSocketImpl.s
at java.net.PlainSocketImpl.d
at java.net.PlainSocketImpl.c
at java.net.PlainSocketImpl.c
at java.net.SocksSocketImpl.c
at java.net.Socket.connect(So
at java.net.Socket.connect(So
at java.net.Socket.<init>(Soc
at java.net.Socket.<init>(Soc
at sun.rmi.transport.proxy.RM
at sun.rmi.transport.proxy.RM
at sun.rmi.transport.tcp.TCPE
... 8 more
If netstat is still giving the same output as before (check) then it looks like the server is not configured to allow your host to connect
ASKER
yes its the same output as before..im confused because ive ran other RMI apps with no problem..Any ideas?
It's possibly a server configuration issue
I'm not so familiar with that, but... could it be some NAT between these two IP adresses?
Probably it's better to ask your sysadmin.
>> Valeri, I havent had problems running servlets with apache tomcat so should this be an issue?
servlets operates on http port, RMI registry uses another port, so it could be an firewall issue!
Probably it's better to ask your sysadmin.
>> Valeri, I havent had problems running servlets with apache tomcat so should this be an issue?
servlets operates on http port, RMI registry uses another port, so it could be an firewall issue!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Could you please post the output of
tracert 195.162.2.1
tracert 195.162.2.1
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)