Question

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

`

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top