1 Reply Latest reply on Oct 20, 2013 5:19 PM by wdfink

    EJB remoting between two servers setup issues

    mschwery

      I'm trying to get a client in a war on one server to make a remote call to an ejb on another server and can't get it to work.

      One the client server I made the following changes to the standalone.xml.

       

      <security-realm name="ejb-security-realm">
          <server-identities>
               <secret value="YWRtaW5gMTI="/>
           </server-identities>
      </security-realm>

       

      <subsystem xmlns="urn:jboss:domain:remoting:1.1">
           <connector name="remoting-connector" socket-binding="remoting"/>
               <outbound-connections>
                  <remote-outbound-connection name="remote-ejb-connection" outbound-socket-binding-ref="remote-ejb-binding">
                   <properties>
                       <property name="SSL_ENABLED" value="false"/>
                       <property name="SASL_POLICY_NOANONYMOUS" value="false"/>
                    </properties>
                 </remote-outbound-connection>
           </outbound-connections>
      </subsystem>

       

      <outbound-socket-binding name="remote-ejb-binding">
          <remote-destination host="localhost" port="4547"/>
      </outbound-socket-binding>

       

      In the client code I have the following.

       

      try {
                    Logger.getLogger("org.jboss").setLevel(Level.OFF);
                    Logger.getLogger("org.xnio").setLevel(Level.OFF);
                    
                   
                    final  Hashtable jndiProps = new Hashtable();
                    jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                    jndiProps.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED","false"); 
                    jndiProps.put("remote.connection.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS","false");
                    jndiProps.put("java.naming.factory.url.pkgs","org.jboss.ejb.client.naming");
                    jndiProps.put("java.naming.factory.initial","org.jboss.naming.remote.client.InitialContextFactory");
                    jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4547");
                    Context ctx = new InitialContext(jndiProps);

       

                   Object obj = ctx.lookup("as7project/SampleBeanRemoteImpl!com.sample.ejb.SampleBeanRemote");
                   SampleBeanRemoteImpl service = (SampleBeanRemoteImpl)obj;
                   service.echo("This is a test");

                   ctx.close();


                } catch (Throwable t) {
                    t.printStackTrace();
                }

       

       

      The EJB which is in a war on the second server started with and offset of 100 is the following.

       

      package com.sample.ejb;

       

      import javax.ejb.Remote;
      import javax.ejb.Stateless;


      @Stateless
      @Remote(SampleBeanRemote.class)
      public class  SampleBeanRemoteImpl implements SampleBeanRemote  {

       

          @Override
          public String echo(String s) {

       

              return "Hello "+s;
          }
      }

       

      The second server says at startup.

      java:global/as7project/SampleBeanRemoteImpl!com.sample.ejb.SampleBeanRemote
      java:app/as7project/SampleBeanRemoteImpl!com.sample.ejb.SampleBeanRemote

      java:module/SampleBeanRemoteImpl!com.sample.ejb.SampleBeanRemote
      java:jboss/exported/as7project/SampleBeanRemoteImpl!com.sample.ejb.SampleBeanRemote
      java:global/as7project/SampleBeanRemoteImpl
      java:app/as7project/SampleBeanRemoteImpl
      java:module/SampleBeanRemoteImpl

       

      The client code is in a war on one server and the ejb is in a war on another server.

      I want the client war to go to the other server to get the ejb, there is no ejb on the server with the look code.

      We are not using security on the ejb.

       

      Is there something in the setup or client code that I am missing.

      I keep getting a "ERROR [stderr] (http-/127.0.0.1:8080-1)     at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory" when I invoke the client code.