Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
java.rmi.ConnectionExceptionException:Connect refused to host

java.rmi.ConnectionExceptionException:Connect refused to host

2004-11-17       - By Kurien Joseph

 Back
Reply:     1     2     3     4     5     6  

*       First check if you can ping both machines from each other.
*       If you still can ping make sure the localhost setting in your
host file to map to the IP address instead of the 127.0.0.1 loopback.



-Kurien





 __ __  

From: A mailing list for Java(tm) 2 Platform, Enterprise Edition
[mailto:J2EE-INTEREST@(protected)] On Behalf Of Edward King
Sent: Wednesday, November 17, 2004 12:41 AM
To: J2EE-INTEREST@(protected)
Subject: java.rmi.ConnectionExceptionException:Connect refused to host



I write a rmi,when server and client runs in the same machine,it runs
ok,then I run them in two machines,server runs in 192.168.0.1,like
follows:
C:\>rmiregistry -J-Djava.security.policy=registerit.policy
C:\>java -Djava.rmi.dgc.leaseValue=1000
-Djava.security.policy=registery.policy RegisterIt
Object instantiated: HelloServer[RemoteStub [ref:
[endpoint:[192.168.0.1:3120](l
ocal),objID:[0]]]]



and it ok ,client runs in 192.168.0.2, but it raise errors:
java -Djava.security.policy=registerit.policy HelloClient
HelloClient exception :java.rmi.ConnectionException:Connection refused
to host:192.168.0.2;nested exception
is:java.net.ConnectException Source code of java.net.ConnectException:Connection refused:connect



Why? how to solve it? I have puzzled with it for many days! Please help.
Any idea will be appreciated!



My code is follows:
--HelloInterface.java--
public interface HelloInterface extends java.rmi.Remote{
public String sayHello() throws java.rmi.RemoteException Source code of java.rmi.RemoteException;
}



--HelloServer.java--
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
public 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();
}
}



--RegisterIt.java--
import java.rmi.*;
public class RegisterIt{
public static void main(String args[]){
try{
HelloServer obj=new HelloServer();
System.out.println("Object instantiated: "+obj);
Naming.rebind("/HelloServer",obj);
System.out.println("HelloServer bound in registery");
}
catch(Exception e){
System.out.println(e);
}
}
}



--registerit.policy--
grant{
permission java.security.AllPermission Source code of java.security.AllPermission;
};



--HelloClient.java--
import java.rmi.*;
public class HelloClient{
public static void main(String args[]){
if(System.getSecurityManager()==null){
System.out.println("null");
System.setSecurityManager(new RMISecurityManager());
}
try{
HelloInterface obj=(HelloInterface)Naming.lookup("/HelloServer");
String message=obj.sayHello();
System.out.println(message);
}
catch(Exception e){
System.out.println("HelloClient exception: "+e);
}
}
}

========================================================================
=== To unsubscribe, send email to listserv@(protected) and include in
the body of the message "signoff J2EE-INTEREST". For general help, send
email to listserv@(protected) and include in the body of the message
"help".


===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".


<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft
-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http:
//www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@(protected)
       {font-family:Wingdings;
       panose-1 (See http://ose-1.ora-code.com):5 0 0 0 0 0 0 0 0 0;}
@(protected)
       {font-family:SimSun;
       panose-1 (See http://ose-1.ora-code.com):2 1 6 0 3 1 1 1 1 1;}
@(protected)
       {font-family:Tahoma;
       panose-1 (See http://ose-1.ora-code.com):2 11 6 4 3 5 4 4 2 4;}
@(protected)
       {font-family:"\@(protected)";
       panose-1 (See http://ose-1.ora-code.com):0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
       {margin:0in;
       margin-bottom:.0001pt;
       font-size:12.0pt;
       font-family:SimSun;}
a:link, span.MsoHyperlink
       {color:blue;
       text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
       {color:purple;
       text-decoration:underline;}
span.EmailStyle17
       {mso-style-type:personal-reply;
       font-family:Arial;
       color:navy;}
@(protected) Section1
       {size:8.5in 11.0in;
       margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
       {page:Section1;}
/* List Definitions */
@(protected) l0
       {mso-list-id:1796213936;
       mso-list-type:hybrid;
       mso-list-template-ids:608627832 1109938394 67698691 67698693 67698689
67698691 67698693 67698689 67698691 67698693;}
@(protected) l0:level1
       {mso-level-start-at:2;
       mso-level-number-format:bullet;
       mso-level-text:\F0B7;
       mso-level-tab-stop:.5in;
       mso-level-number-position:left;
       text-indent:-.25in;
       font-family:Symbol;
       mso-fareast-font-family:SimSun;
       mso-bidi-font-family:Arial;}
ol
       {margin-bottom:0in;}
ul
       {margin-bottom:0in;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
 <o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=white lang=EN-US link=blue vlink=purple>

<div class=Section1>

<ul style='margin-top:0in' type=disc>
<li class=MsoNormal style='color:navy;mso-list:l0 level1 lfo1'><font size=2
    color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial'
>First
    check if you can ping both machines from each other.<o:p></o:p></span><
/font></li>
<li class=MsoNormal style='color:navy;mso-list:l0 level1 lfo1'><font size=2
    color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial'>If
    you still can ping make sure the localhost setting in your host file to
    map to the IP address instead of the 127.0.0.1 loopback.<o:p></o:p></span>
</font></li>
</ul>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>-Kurien<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face=SimSun><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> A mailing list
for Java(tm) 2 Platform, Enterprise Edition [mailto:J2EE-INTEREST@(protected)]
<b><span style='font-weight:bold'>On Behalf Of </span></b>Edward King<br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, November 17, 2004
12:41 AM<br>
<b><span style='font-weight:bold'>To:</span></b> J2EE-INTEREST@(protected)<br>
<b><span style='font-weight:bold'>Subject:</span></b>
java.rmi.ConnectionExceptionException:Connect refused to host</span></font><o:p
></o:p></p>

</div>

<p class=MsoNormal><font size=3 face=SimSun><span style='font-size:12.0pt'><o:p
>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><font size=2 face=SimSun><span style='font-size:10.0pt'>I
write a rmi,when server and client runs in the same machine,it runs ok,then I
run them in two machines,server runs in 192.168.0.1,like follows:<br>
C:\&gt;rmiregistry -J-Djava.security.policy=registerit.policy<br>
C:\&gt;java -Djava.rmi.dgc.leaseValue=1000
-Djava.security.policy=registery.policy RegisterIt<br>
Object instantiated: HelloServer[RemoteStub [ref:
[endpoint:[192.168.0.1:3120](l<br>
ocal),objID:[0]]]]</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt;font-family:"Times New Roman"'>&nbsp;</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 face=SimSun><span style='font-size:10.0pt'>and
it ok ,client runs in 192.168.0.2, but it raise errors:<br>
java -Djava.security.policy=registerit.policy HelloClient<br>
HelloClient exception :java.rmi.ConnectionException:Connection refused to
host:192.168.0.2;nested exception is:java.net.ConnectException Source code of java.net.ConnectException:Connection
refused:connect</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt;font-family:"Times New Roman"'>&nbsp;</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 face=SimSun><span style='font-size:10.0pt'>Why?
how to solve it? I have puzzled with it for many days! Please help.<br>
Any idea will be appreciated!</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 face="Times New Roman"><span style='font-size:
10.0pt;font-family:"Times New Roman"'>&nbsp;</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 face=SimSun><span style='font-size:10.0pt'>My
code is follows:<br>
--HelloInterface.java--<br>
public interface HelloInterface extends java.rmi.Remote{<br>
public String sayHello() throws java.rmi.RemoteException Source code of java.rmi.RemoteException;<br>
}</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt;font-family:"Times New Roman"'>&nbsp;</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 face=SimSun><span style='font-size:10.0pt'>-
-HelloServer.java--<br>
import java.io.*;<br>
import java.rmi.*;<br>
import java.rmi.server.*;<br>
import java.util.*;<br>
public class HelloServer extends UnicastRemoteObject implements HelloInterface{
<br>
public HelloServer() throws RemoteException{<br>
super();<br>
}</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt;font-family:"Times New Roman"'>&nbsp;</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 face=SimSun><span style='font-size:10.0pt'
>public
String sayHello() throws RemoteException{<br>
return &quot;Hello world, the current system time is &quot;+new Date();<br>
}<br>
}</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt;font-family:"Times New Roman"'>&nbsp;</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 face=SimSun><span style='font-size:10.0pt'>-
-RegisterIt.java--<br>
import java.rmi.*;<br>
public class RegisterIt{<br>
public static void main(String args[]){<br>
try{<br>
HelloServer obj=new HelloServer();<br>
System.out.println(&quot;Object instantiated: &quot;+obj);<br>
Naming.rebind(&quot;/HelloServer&quot;,obj);<br>
System.out.println(&quot;HelloServer bound in registery&quot;);<br>
}<br>
catch(Exception e){<br>
System.out.println(e);<br>
} <br>
}<br>
}</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt;font-family:"Times New Roman"'>&nbsp;</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 face=SimSun><span style='font-size:10.0pt'>-
-registerit.policy--<br>
grant{<br>
permission java.security.AllPermission Source code of java.security.AllPermission;<br>
}; </span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt;font-family:"Times New Roman"'>&nbsp;</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=2 face=SimSun><span style='font-size:10.0pt'>-
-HelloClient.java--<br>
import java.rmi.*;<br>
public class HelloClient{<br>
public static void main(String args[]){<br>
if(System.getSecurityManager()==null){<br>
System.out.println(&quot;null&quot;);<br>
System.setSecurityManager(new RMISecurityManager());<br>
}<br>
try{<br>
HelloInterface obj=(HelloInterface)Naming.lookup(&quot;/HelloServer&quot;);<br>
String message=obj.sayHello();<br>
System.out.println(message);<br>
}<br>
catch(Exception e){<br>
System.out.println(&quot;HelloClient exception: &quot;+e);<br>
}<br>
}<br>
}</span></font><o:p></o:p></p>

</div>

</div>

</body>

</html>
===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".
<p>
===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".
<p>

©2008 junlu.com - Jax Systems, LLC, U.S.A.