• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Java RMI App in two different VM(s)  RSS feed

 
Greenhorn
Posts: 2
Java Linux PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I tried to create Java RMI program and everything goes very well when I used one machine or I used host and VM. However, the programs is not working when I run it on two different VM(s).

on VM1, I run 'rmiregistry' and 'java server <serverIP>' - Works

on VM2, I run 'java client <serverIP>' - ERROR

Error :

Exception in thread "main" java.rmi.ConnectIOException: Exception creating connection to: 192.168.122.30; nested exception is: java.net.NoRouteToHostException: No route to host (Host unreachable)



I have tried :

  • Put the specific port under the implementation.java 'super()'
  • Use the hostname@<serverIP>
  • Inject the ipaddress in code
  • Run server using -Djava.rmi.server.hostname=<serverIP>

  • Still isnt working.

    SSH, telnet, ping, and traceroute are working
    Here my Code

    Client.java


    Server.java



    Thank you!
     
    Sheriff
    Posts: 24366
    55
    Eclipse IDE Firefox Browser MySQL Database
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Jane Cour wrote:Exception in thread "main" java.rmi.ConnectIOException: Exception creating connection to: 192.168.122.30; nested exception is: java.net.NoRouteToHostException: No route to host (Host unreachable)



    This error doesn't actually have anything to do with RMI -- it simply means that the client JVM can't connect to the server JVM because there's no network connection between the two machines they are running on.

    But you said that ping was working? Does that mean that from the machine where VM2 is running you got a command line and tried to ping the machine where VM1 is running, and ping connected? If that's the case then I think you probably have to find somebody to help you with the network configuration, perhaps there's a firewall in the way or something like that.
     
    Saloon Keeper
    Posts: 20635
    122
    Android Eclipse IDE Java Linux Redhat Tomcat Server
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Seconded. It's almost certainly firewall issues. An RMI server publishes its registry on tcp port 1099. However, when a client connects, the port that it then uses is unpredictable. The system assigns a separate port number for each client/server session.

    RMI, like CORBA, was designed in an era when there was more trust on networks. CORBA is mostly history, but RMI still has occasional uses. For more information on how to deal with RMI in an age of firewalls, see this: https://docs.oracle.com/javase/7/docs/platform/rmi/spec/rmi-arch6.html

    The firewall issue is one reason that web services are so popular now, since virtually no machines block the http and https ports. Message Brokers also fill a niche there. However EJB3 remote beans do use RMI-IIOP.
     
    Jane Cour
    Greenhorn
    Posts: 2
    Java Linux PHP
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for all the responses!

    I already figured it out how to solve it and I hope this will be helpful for others.

    To get the vm talking each other, the programs do not have any problems but the firewall on vm(s) is. So before running the programs, please make sure, the firewalld is disabled and stop running. Then, It will work.

    Run this command in the vm(s)



    Dont forget to enable and run your firewalld after this!

    Thanks!
     
    Tim Holloway
    Saloon Keeper
    Posts: 20635
    122
    Android Eclipse IDE Java Linux Redhat Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I really don't recommend that. Athough you may not have any direct-to-Internet connections on that VM, I prefer to lower my guards as little as possible. So if I'm running services like RMI or backend databases on a DMZ LAN, I set up the firewall to permit requests originating from within the DMZ, while still blocking external requests. So, for example, if my DMZ is subnet 10.14.0.0/16, I'd add this rule:


    There actually are firewall services that understand mechanisms like RMI and can dynamically allow the RMI connection - something like that is used with the FTP rules. But I'm not conversant with anything specific to RMI itself.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!