2 Replies Latest reply on Oct 24, 2012 1:03 PM by wdfink

    Problems accessing JBoss over static IP

    etp_scm

      Hi,

      I am using JBoss 6.1.0 for my example. I have deployed my EJB project on a machine and have allocated a static IP to the machine and have written a sample Java client which is remotely invoking the bean class.

      But some how I am getting an error at the lookup stage.It tries to connect to the host name instead of the IP address, so was just wondering if JBoss has got to do anything with this

       

      And when I do the same with my Server on LAN instead of static IP, everything works properly.

      Below is the client code which  im using in my example

       

       

       

       

      package com.client;

       

       

      import java.rmi.RemoteException;

      import java.util.Properties;

       

       

      import javax.ejb.CreateException;

      import javax.naming.Context;

      import javax.naming.InitialContext;

      import javax.naming.NamingException;

      import javax.rmi.PortableRemoteObject;

       

       

      import com.mypkg.ISampleServiceHome;

      import com.mypkg.ISampleServiceRemote;

       

       

       

       

       

      public class EJBInvoker {

                public static void main(String args[])

                {

                          Context ctx= null;

                          Properties prop=new Properties();

                          prop.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.NamingContextFactory");

                          prop.put(Context.PROVIDER_URL,"jnp://203.199.104.155:1099");

                          ISampleServiceHome home = null;

                          ISampleServiceRemote remote =  null;

       

                          try

                          {

                                    ctx = new InitialContext(prop);

       

                                    Object obj  = ctx.lookup("MyEJBService");

       

                                    home = (ISampleServiceHome)PortableRemoteObject.narrow(obj,ISampleServiceHome.class);

       

                                    remote =   home.create();

                                    remote.display();

       

                          }

                          catch (NamingException e) {

                                    // TODO Auto-generated catch block

                                    e.printStackTrace();

                          } catch (RemoteException e) {

                                    // TODO Auto-generated catch block

                                    e.printStackTrace();

                          } catch (CreateException e) {

                                    // TODO Auto-generated catch block

                                    e.printStackTrace();

                          }

       

       

       

                }

       

       

      }

       

       

      Below is the stack trace which im getting :

       

       

       

      javax.naming.CommunicationException [Root exception is

      java.rmi.ConnectException: Connection refused to host: etp-05-149;

      nested exception is:

           java.net.ConnectException: Connection refused: connect]

           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:841)

           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)

           at javax.naming.InitialContext.lookup(Unknown Source)

           at com.client.EJBInvoker.main(EJBInvoker.java:34)

      Caused by: java.rmi.ConnectException: Connection refused to host:

      etp-05-149; nested exception is:

           java.net.ConnectException: Connection refused: 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.invoke(Unknown Source)

           at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)

           at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)

           ... 3 more

      Caused by: java.net.ConnectException: Connection refused: connect

           at java.net.PlainSocketImpl.socketConnect(Native Method)

           at java.net.PlainSocketImpl.doConnect(Unknown Source)

           at java.net.PlainSocketImpl.connectToAddress(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 Source)

           at

      sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)

           ... 9 more

       

       

      Regards,

       

      Jatin Chanchlani

        • 1. Re: Problems accessing JBoss over static IP
          erasmomarciano

          Hi

           

           

          You ping this host?

           

          Connection refused to host: etp-05-149

           

           

          nested exception is:

               java.net.ConnectException: Connection refused: connect]

               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:841)

               at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)

               at javax.naming.InitialContext.lookup(Unknown Source)

               at com.client.EJBInvoker.main(EJBInvoker.java:34)

          Caused by: java.rmi.ConnectException: Connection refused to host:

          etp-05-149; nested exception is:

               java.net.ConnectException: Connection refused: connect


          • 2. Re: Problems accessing JBoss over static IP
            wdfink

            What if you ping the machine with the IP and the host name? Maybe the DNS or some network settings are wrong.

             

            How do you start JBoss, do you use "-b <your ip>" ?