title: jboss-as-7.1.1.Final to jboss-5.1.0.GA ejb lookup
body: <p>After seeing many variations of my question, I still have not found an answer yet so I would greatly appreciate it if someone gave me some insight.</p>
  
  <p>Can anyone tell me what is the best way to lookup ejb 3.1 on AS 5 (on a server) from AS 7 (localhost)?</p>
  
  <p>Here's how I do the lookup from my Java class:</p>
  
  <pre><code>Hashtable&lt;String, String&gt; env = new Hashtable&lt;String, String&gt;();
  env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
  env.put(Context.PROVIDER_URL, "remote://serverName:port#");
  env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jboss.naming.remote.client");
  
  SomeService someService = (SomeService) new InitialContext(env).lookup("ejb:some-enterprise-ear-1.0-SNAPSHOT/some-ejb-1.0-SNAPSHOT/SomeServiceBean!some.ejb.SomeService");
  </code></pre>
  
  <p>I then modified the standalone.xml to include outbound-connections element as follows:</p>
  
  <pre><code>    &lt;subsystem xmlns="urn:jboss:domain:remoting:1.1"&gt;
          &lt;connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/&gt;
          &lt;outbound-connections&gt;
              &lt;remote-outbound-connection name="remote-ejb-connection" outbound-socket-binding-ref="remote-ejb" username="userA" security-realm="ejb-security-realm"&gt;
                  &lt;properties&gt;
                      &lt;property name="SASL_POLICY_NOANONYMOUS" value="false"/&gt;
                      &lt;property name="SSL_ENABLED" value="false"/&gt;
                  &lt;/properties&gt;
              &lt;/remote-outbound-connection&gt;
          &lt;/outbound-connections&gt;
      &lt;/subsystem&gt;
  </code></pre>
  
  <p>&amp; outbound-socket-binding as follows:</p>
  
  <pre><code>&lt;socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"&gt;
        &lt;socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/&gt;
        &lt;socket-binding name="management-http" interface="public" port="${jboss.management.http.port:9990}"/&gt;
        &lt;socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/&gt;
        &lt;socket-binding name="ajp" port="8009"/&gt;
        &lt;socket-binding name="http" port="8080"/&gt;
        &lt;socket-binding name="https" port="8443"/&gt;
        &lt;socket-binding name="osgi-http" interface="management" port="8090"/&gt;
        &lt;socket-binding name="remoting" port="1100"/&gt;
        &lt;socket-binding name="txn-recovery-environment" port="4712"/&gt;
        &lt;socket-binding name="txn-status-manager" port="4713"/&gt;
        &lt;outbound-socket-binding name="mail-smtp"&gt;
            &lt;remote-destination host="localhost" port="25"/&gt;
        &lt;/outbound-socket-binding&gt;
        &lt;outbound-socket-binding name="remote-ejb"&gt;
            &lt;remote-destination host="serverName" port="port#"/&gt;
        &lt;/outbound-socket-binding&gt;
  &lt;/socket-binding-group&gt;
  </code></pre>
  
  <p>I have added jboss-ejb-client.xml in the META-INF folder with the contents:</p>
  
  <pre><code>&lt;jboss-ejb-client xmlns="urn:jboss:ejb-client:1.0"&gt;
      &lt;client-context&gt;
            &lt;ejb-receivers&gt;
                &lt;remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection"/&gt;
            &lt;/ejb-receivers&gt;
      &lt;/client-context&gt;
  &lt;/jboss-ejb-client&gt;
  </code></pre>
  
  <p>When I run my application I get the following exception:</p>
  
  <pre><code>Caused by: javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: java.io.IOException: Received an invalid message length of -1393754107]
  at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
  at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
  at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
  at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
  at javax.naming.InitialContext.init(InitialContext.java:242)
  at javax.naming.InitialContext.&lt;init&gt;(InitialContext.java:216)
  at za.co.fnb.smc.integration.service.SMCCAREIntgrationService.&lt;init&gt;(SMCCAREIntgrationService.java:39)
  ... 1 more
  
  Caused by: java.lang.RuntimeException: java.io.IOException: Received an invalid message length of -1393754107
  at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:87)
  at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:56)
  at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:166)
  at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:139)
  at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
  ... 6 more
  
  Caused by: java.io.IOException: Received an invalid message length of -1393754107
  at org.xnio.channels.FramedMessageChannel.receive(FramedMessageChannel.java:104)
  at org.jboss.remoting3.remote.ClientConnectionOpenListener$Greeting.handleEvent(ClientConnectionOpenListener.java:138)
  at org.jboss.remoting3.remote.ClientConnectionOpenListener$Greeting.handleEvent(ClientConnectionOpenListener.java:130)
  at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)
  at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:189)
  at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:103)
  at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:72)
  at org.xnio.nio.NioHandle.run(NioHandle.java:90)
  at org.xnio.nio.WorkerThread.run(WorkerThread.java:184)
  at ...asynchronous invocation...(Unknown Source)
  at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:270)
  at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:251)
  at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:349)
  at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:333)
  at org.jboss.naming.remote.client.EndpointCache$EndpointWrapper.connect(EndpointCache.java:105)
  at org.jboss.naming.remote.client.NamingStoreCache.getRemoteNamingStore(NamingStoreCache.java:55)
  ... 9 more
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>telnet 10.33.42.7 1100
  
  Trying 10.33.42.7...
  Connected to 10.33.42.7.
  Escape character is '^]'.
  m�srjava.rmi.MarshalledObject|���c�&gt;IhashlocBytest[BobjBytesq~xp
  ur[B���T�xpC��thttp://kccintccjb11:8083/q~q~q~q~q~q~q~uq~7��s}  org.jnp.interfaces.Naming,org.jboss.ha.framework.interfaces.HARMIProxyxrjava.lang.reflect.Proxy�'� �C�Lht%Ljava/lang/reflect/InvocationHandler;xpsr-org.jboss.ha.framework.interfaces.HARMIClient���j��ّLfamilyClusterInfot5Lorg/jboss/ha/framework/interfaces/FamilyClusterInfo;LkeytLjava/lang/String;LloadBalancePolicyt3Lorg/jboss/ha/client/loadbalance/LoadBalancePolicy;xpwCCINT01/HAJNDIsrjava.util.ArrayListx����a�Isizexpwsr2org.jboss.ha.framework.server.HARMIServerImpl_Stubxrjava.rmi.server.RemoteStub���ɋ�exrjava.rmi.server.RemoteObject�a��
                                                                                                          a3xpw7
                                                                                                                  UnicastRef2
                                                                                                                             kccintccjb01MFV�K����B׆j`�xsq~
                                                                                                                                                                w7
                                                                                                                                                                  UnicastRef2
                                                                                                                                                                             k'sr,org.jboss.ha.framework.interfaces.RoundRobinx.���:xpxConnection closed by foreign host.
  </code></pre>
  
  <p><strong><em>Remoting in the target server</em></strong></p>
  
  <pre><code>        &lt;!-- ********************* deploy/cluster/hajndi-service.xml ****************** --&gt;
          &lt;bean class="org.jboss.services.binding.ServiceBindingMetadata"&gt;
             &lt;property name="serviceName"&gt;jboss:service=HAJNDI&lt;/property&gt;
             &lt;property name="bindingName"&gt;Port&lt;/property&gt;
             &lt;property name="port"&gt;1100&lt;/property&gt;
             &lt;property name="description"&gt;The listening socket for the HA-JNDI service&lt;/property&gt;
          &lt;/bean&gt;
  
          &lt;bean class="org.jboss.services.binding.ServiceBindingMetadata"&gt;
             &lt;property name="serviceName"&gt;jboss:service=HAJNDI&lt;/property&gt;
             &lt;property name="bindingName"&gt;RmiPort&lt;/property&gt;
             &lt;property name="port"&gt;1101&lt;/property&gt;
             &lt;property name="description"&gt;Socket HA-JNDI service uses to receive RMI requests from client proxies&lt;/property&gt;
          &lt;/bean&gt;
  
          &lt;!-- HA RMI/JRMP invoker --&gt;
          &lt;bean class="org.jboss.services.binding.ServiceBindingMetadata"&gt;
             &lt;property name="serviceName"&gt;jboss:service=invoker,type=jrmpha&lt;/property&gt;
             &lt;property name="port"&gt;4447&lt;/property&gt;
             &lt;property name="description"&gt;Socket for high availability version of the legacy RMI/JRMP invoker&lt;/property&gt;
          &lt;/bean&gt;
  </code></pre>
  
  <p>When I do a google search on java.io.IOException: Received an invalid message length of -1393754107, I found the following resources (although helpful, I still don't get to the solution):</p>
  
  <p><a href="https://stackoverflow.com/questions/10545043/how-to-lookup-ejb-on-jboss-as-7-x">How to lookup ejb on JBoss AS 7.x</a></p>
  
  <p><a href="https://community.jboss.org/message/569391#569391" rel="nofollow noreferrer">https://community.jboss.org/message/569391#569391</a></p>
  
  <p>I'd appreciate any suggestions | ideas.</p>
  
  <p>Thank You in Advance</p>