aspose file tools*
The moose likes Distributed Java and the fly likes Basic RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Basic RMI" Watch "Basic RMI" New topic
Author

Basic RMI

Cyril Sadasivan
Greenhorn

Joined: Jul 17, 2012
Posts: 22
I have just started trying out RMI..
I have the Server class and Client class on different machines. rmiregistry was started on Server machine. properties were set using jndi.properties files at server and client

for the below Java code :

service:


remote interface :


server:

properties file at server:
java.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory
java.naming.provider.url=rmi://localhost:1099

client:

properties file at client:
java.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory
java.naming.provider.url=rmi://120.61.40.49:1099

i get the below error when i run the Client class:

javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectExce
ption: Connection refused to host: 120.61.40.49; nested exception is:
java.net.ConnectException: Connection timed out: connect]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at Client.main(Client.java:6)
Caused by: java.rmi.ConnectException: Connection refused to host: 120.61.40.49;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
... 4 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
... 9 more


Can anyone suggest what i am doing wrong?
rohit chavan
Ranch Hand

Joined: Oct 08, 2010
Posts: 131

Hi,

Are you able to ping the server IP (i.e. 120.61.40.49) from client machine?
Cyril Sadasivan
Greenhorn

Joined: Jul 17, 2012
Posts: 22
Hi Rohit,

I did ping the server machine. But I see the IP address has changed.

G:\client>ping 120.61.112.250

Pinging 120.61.112.250 with 32 bytes of data:

Reply from 120.61.112.250: bytes=32 time<1ms TTL=254
Reply from 120.61.112.250: bytes=32 time<1ms TTL=254
Reply from 120.61.112.250: bytes=32 time<1ms TTL=254
Reply from 120.61.112.250: bytes=32 time<1ms TTL=254

Ping statistics for 120.61.112.250:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

But there was no luck with the Java program
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Basic RMI
 
Similar Threads
RMI Call Works on Same Host, Fails Over Network
rmi connection refused if not 1099
JRun4 - Connection error
connecting to MS-Access
error executing Head First EJB first example