Community   SpringSource   Projects    Downloads    Documentation    Forums    Training   Exchange   Blogs

Go Back   Spring Community Forums > Core Spring Projects > Remoting and JMS

Reply
 
Thread Tools Display Modes
  #1  
Old Jan 17th, 2007, 03:54 AM
thosmas thosmas is offline
Junior Member
 
Join Date: Oct 2004
Posts: 4
Default RMI invocation attempts connecting to 127.0.0.1

Hi

I've exported a bean by using the RmiServiceExporter, and tries to access this bean through the RmiProxyFactoryBean. This works fine when client and server is on the same host, but fails with the following exception when client is set up on a different host. I have ofcourse set the RmiProxyFactoryBean.serviceUrl correctly, and the remote object is found, but as the exception shows it is the invocation of a method on the remote object that fails with a connect failure to 127.0.0.1. Why is the loopback address being used? I found from the javadocs of RmiServiceExporter a suggestion to set -Djava.rmi.server.host , but this does not seem to help. [using spring 2.0]

Exception in thread "main" org.springframework.remoting.RemoteConnectFailureE xception: Cannot connect to remote service [rmi://bernt:2000/Admin]; nested exception is java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused
Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEnd point.java:574)
at sun.rmi.transport.tcp.TCPChannel.createConnection( TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCP Channel.java:171)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:9 4)
at org.springframework.remoting.rmi.RmiInvocationWrap per_Stub.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiClientIntercep tor.doInvoke(RmiClientInterceptor.java:400)
at org.springframework.remoting.rmi.RmiClientIntercep tor.doInvoke(RmiClientInterceptor.java:344)
at org.springframework.remoting.rmi.RmiClientIntercep tor.invoke(RmiClientInterceptor.java:259)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :185)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:209)
at $Proxy0.settle(Unknown Source)
[CUT]
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl .java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSoc ketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:179)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.cre ateSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.cre ateSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEnd point.java:569)
... 24 more
Reply With Quote
  #2  
Old Jan 18th, 2007, 08:42 AM
thosmas thosmas is offline
Junior Member
 
Join Date: Oct 2004
Posts: 4
Default Solved

Finally figured this out. RMI uses the following method to obtain a server hostname:

http://java.sun.com/j2se/1.4.2/docs/...ml#nethostname

In my case the IP returned was 127.0.0.1 due to the setup on my linux box
(see http://www.jguru.com/faq/view.jsp?EID=790132).
By changing the OS setup i got the correct external IP address returned.

Strange though that neither -Djava.rmi.server.host=$HOSTNAME nor -Djava.rmi.server.useLocalHostname=true did the job.
Reply With Quote
  #3  
Old Feb 14th, 2007, 11:22 AM
bindiya bindiya is offline
Junior Member
 
Join Date: Feb 2007
Posts: 1
Default

Hi

I too face same problem.

Did you get it working???
Please let me know.

Thanks,
Bindiya
Reply With Quote
  #4  
Old Mar 13th, 2007, 10:05 AM
mhollins mhollins is offline
Junior Member
 
Join Date: Mar 2007
Posts: 2
Default

I am having the exact same problem. Could you please post your exact changes to fix it? Thank You.
Reply With Quote
  #5  
Old Mar 13th, 2007, 11:11 AM
mhollins mhollins is offline
Junior Member
 
Join Date: Mar 2007
Posts: 2
Default figured it out

Well, since I didn't have time to wait for a reply, I went ahead and banged my head against it for a little while and figured out what to do.

After re-reading the links from thosmas' posts, I realized that it was the hosts file on the server that needed to be fixed.

If your hosts file has the first line as:
Code:
127.0.0.1    localhost  {hostname}
you must remove the {hostname} from that first line and add another line like:
Code:
{actual ip address}   {hostname}
That worked for me.
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:28 AM.


Contegix provides first-class managed hosting and partial sponsorship of these forums.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.