0

I have a cloud instance where i have installed Jboss5.0.1GA server. Server instance contains a Public ip and a natted Ip Address. I have run Jboss server using -b with ip(natted) address and web url is working fine. Now i am creating Java external client to access EJB3 bean which is deployed in Jboss server where i am getting the exception and trying solution using google which is not helped my case. Find below code which tells what i am using in external client to access EJB3.

                            properties = new Properties();
            properties.load(stream);
            // Set the context
            Hashtable ht = new Hashtable();
            ht.put(Context.INITIAL_CONTEXT_FACTORY,
                    "org.jnp.interfaces.NamingContextFactory");
            ht.put(Context.PROVIDER_URL,"public ip address");
            ht.put(Context.URL_PKG_PREFIXES,
                    "org.jboss.naming:org.jnp.interfaces");
            // Find and create a reference to the bean using JNDI
            context = new InitialContext(ht);

While executing it localhost its working fine. While connecting remote throwing below exception. "javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: ". Can anyone help me on the same.

`This is my connector file(ejb3-connectors-jboss-beans.xml).

EJB3 Connectors

-->

JBoss Remoting Connector  

Note: Bean Name "org.jboss.ejb3.RemotingConnector" is used
as a lookup value; alter only after checking java references
to this key.

-->

<property name="invokerLocator">

  <value-factory bean="ServiceBindingManager"
    method="getStringBinding">
    <parameter>
      jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3
    </parameter>
    <parameter>
      <null />
    </parameter>
    <parameter>socket://${jboss.bind.address}:${port}</parameter>
    <parameter>
      <null />
    </parameter>
    <parameter>3873</parameter>
  </value-factory>

</property>
<property name="serverConfiguration">
  <inject bean="ServerConfiguration" />
</property>

AOP org.jboss.aspects.remoting.AOPRemotingInvocationHandler

`

Palani
  • 1,891
  • 7
  • 31
  • 42

2 Answers2

1

Do a telnet to the ip and port you are trying to connect on the jboss from the remote server instance. If that's not working then you have to solve networking issues first. (Let me know, so I can guide you on how to do it)

Also check your EJB3 binding settings and check networking. Out of the box config looks looks this..

   <mbean code="org.jboss.remoting.transport.Connector"
          xmbean-dd="org/jboss/remoting/transport/Connector.xml"
          name="jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3">
      <depends>jboss.aop:service=AspectDeployer</depends>
      <attribute name="InvokerLocator">socket://0.0.0.0:3873</attribute>
      <attribute name="Configuration">
         <handlers>
            <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
         </handlers>
      </attribute>
   </mbean>

Thanks!

@leo.

lemil77
  • 341
  • 1
  • 8
  • I tried using natted ip address and also your option.(run.bat -b 0.0.0.0) but its not solved my issue. My server has firewall restrictions and i have opened all basic port.is there any other option i am missing here? – Palani Mar 17 '13 at 16:54
  • Are you able to access the ejb endpoints (usually 8080) and jndi port (usually 1099) from the remote server using a telnet connection?. If your machine has several instances or special configs, these default values may change. – lemil77 Mar 17 '13 at 16:57
  • @leo i am getting below one and seems telnet can able access it.¼φsr↓java.rmi.MarshalledObject|╜▲ùφcⁿ>☻♥I♦hashlocBytest☻[BobjBytesq~☺xp0≤[╨ur☻[B ↨°Tα☻xp*¼φt↓http://localip:8083/q~q~uq~♥├¼φsr org.jnp.server.NamingServer_S tub☻☻xrjava.rmi.server.RemoteStubΘ■▄╔ïße☻xr∟java.rmi.server.RemoteObject╙a┤æ a3▲♥ xpw7 UnicastRef2 localip♦J^uYPΓñª║▐a☺=yBlYÇ☺x Connection to host lost. – Palani Mar 17 '13 at 17:02
  • @leo last line shows "connection to host lost" is that sense any issue? – Palani Mar 17 '13 at 17:05
  • Can you paste the config of the ebj3 connector key (from jboss console). Typically... jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3 – lemil77 Mar 17 '13 at 17:31
  • @Leo I have added my connector file in my question itself as i could not paste it here. – Palani Mar 17 '13 at 17:52
  • Can you try telnet to port 3873, from the remote machine?. If connects, then check if the @Remote interface of the EJB is in place. – lemil77 Mar 17 '13 at 23:44
  • @Leo yes the port is running fine and also checked my remote interface and it looks fine. It seems that socket creation is getting failed @ remote server.Still searching for the root cause :(.Thanks – Palani Mar 18 '13 at 11:45
  • Finally got the solution :). To my case below 2 things worked for me. 1.Running Jboss server using run.bat -b public ip(not nat ip) -Djboss.bind.address=0.0.0.0 and 2. Enabling my local machine hosts to point remote ip to remote hostname. – Palani Mar 20 '13 at 08:02
0

To my case below 2 things worked for me. 1. Running Jboss server using run.bat -b **public ip(not nat ip)** -Djboss.bind.address=0.0.0.0 2. Enabling my **local** machine hosts file to point remote ip to hostname ie remoteip remotehostname. Hope it will help to others as well.

Palani
  • 1,891
  • 7
  • 31
  • 42