0 Replies Latest reply on Nov 11, 2014 5:11 AM by soloknight

    Q: JBoss 5 with nat issue and rmi

    soloknight

      Hi:

       

      Stuck with following issue for a few days, need your guys help.....hopefully

       

      Condition: centos6, JBoss 5, two vlans and both configured with nat, a java test program

       

      Basiclly i need to establish a connection between Jboss and a Java test program,

       

      this jboss is in a vlan, say it internal ip is 192.168.10.3 and done with nat, its external ip is 58.115.117.33.

      configed with hostname  192.168.10.3  test.com

       

      Then, the java test program is in another vlan, internal ip 20.20.3.49  and some external ip,

      and add 58.114.117.33 test.com at its /etc/hosts

       

      java code as follows:

       

      public void test() throws NamingException{       


      System.out.println("------start1-------");       

      Context jbossCtx = getJBossInitialContext();       

      System.out.println("------start5-------");       

      HelloWorldRemote myEJB =(HelloWorldRemote)jbossCtx.lookup("java:/HelloEJB");       

      System.out.println("------start6-------");       

            

       

      private Context getJBossInitialContext()      {        

      System.out.println("------start2-------");       

      final String INIT_FACTORY="org.jnp.interfaces.NamingContextFactory";       

      final String SERVER_URL="test.longskysoft.com:41099";       

      Context ctx=null;       

      try{           

      System.out.println("------start3-------");         

      Properties props = new Properties();        

      props.put(Context.INITIAL_CONTEXT_FACTORY,INIT_FACTORY);         

      props.put(Context.PROVIDER_URL, SERVER_URL);         

      ctx= new InitialContext(props);         

      System.out.println("------start4-------");        }       

      catch (NamingException ne){         

      System.err.println("something");        

      ne.printStackTrace();        }       

      return ctx;      }          


      public static void main(String[] args) throws Exception      {         


      System.out.println("------start-------");         

      HelloWorldClientTest  client= new HelloWorldClientTest();      

      client.test();           


      }




      try to start as


      ./run.sh -c default -b 0.0.0.0 -Djava.rmi.server.hostname=58.115.117.33 -Djava.rmi.server.uselocalHostname=false;



      and get error msg like :

      connection refused to 58.115.117.33, java.net.connectexception : time out




      howerver,


      i can start with no error msg as ./run.sh -c default -b 0.0.0.0, but the java side will return

      connection refused to test.com nested exception is java.net.connectexception : connection refused