8 Replies Latest reply on Apr 17, 2012 3:27 AM by jaikiran

    JBoss 7 remote JNDI

    s3lvatico

      Hello everyone,

      I'm trying to carry out some simple experiments in accessing an EJB's remote view from a client.

      I (seem to have) followed all the instructions in the document https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI ,

      with the only difference being the fact that I boiled down the remote interface to a single adder method, like this:

       

       

      public interface RemoteAdder {
         int add(int x, int y);
      }
      

       

      ....and the implementing bean

       

      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      
      
      @Stateless
      @Remote(RemoteAdder.class)
      public class AdderBean implements RemoteAdder {
      
      
         @Override
         public int add(int x, int y) {
            return x + y ;
         }
      }
      

       

      The deployment goes fine:

       

      00:09:39,674 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015003: Found LeEJBon7.jar in deployment directory. To trigger deployment create a f

      ile called LeEJBon7.jar.dodeploy

      00:09:39,674 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) Starting deployment of "LeEJBon7.jar"

      00:09:39,704 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named AdderBean in deplo

      yment unit deployment "LeEJBon7.jar" are as follows:

       

       

              java:global/LeEJBon7/AdderBean!org.gmnz.as7.RemoteAdder

              java:app/LeEJBon7/AdderBean!org.gmnz.as7.RemoteAdder

              java:module/AdderBean!org.gmnz.as7.RemoteAdder

              java:global/LeEJBon7/AdderBean

              java:app/LeEJBon7/AdderBean

              java:module/AdderBean

       

       

      00:09:39,724 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018559: Deployed "LeEJBon7.jar"

       

      The client code looks ludicrously simple:

       

      import java.util.Properties;
      
      
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      
      
      public class LeRemote {
      
      
         public static void main(String[] args) {
      
      
            Properties jndiProps = new Properties();
            jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
            try {
               InitialContext context = new InitialContext(jndiProps);
               final String appName = "";
               final String moduleName = "LeEJBon7";
               final String distinctName = "";
               final String beanName = AdderBean.class.getSimpleName();
               final String viewClassName = RemoteAdder.class.getName();
               RemoteAdder adderEjb = (RemoteAdder) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/"
                     + beanName + "!" + viewClassName);
               int x = adderEjb.add(3, 5);
               System.out.println(x);
            }
            catch (NamingException e) {
               e.printStackTrace();
            }
         }
      }
      

       

       

      The client is located in a simple java project with the required jar for remoting configured as an Eclipse user library:

      ejb_client_project.png

       

       

      ...and here's the required properties file:

       

      remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

       

      remote.connections=default

       

      remote.connection.default.host=localhost

      remote.connection.default.port=4447

      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

       

       

      Still, when I run the client I get this error output on the client side:

       

      INFO: XNIO NIO Implementation Version 3.0.0.CR5

      22-gen-2012 0.23.09 org.jboss.remoting3.EndpointImpl <clinit>

      INFO: JBoss Remoting version 3.2.0.CR6

      22-gen-2012 0.23.09 org.jboss.ejb.client.remoting.VersionReceiver handleMessage

      INFO: Received server version 1 and marshalling strategies [river]

      22-gen-2012 0.23.09 org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate

      INFO: Successful version handshake completed for receiver context org.jboss.ejb.client.EJBReceiverContext@5e0feb48 on channel Channel ID c1219afb (outbound) of Remoting connection 6ee0a386 to localhost/127.0.0.1:4447

      22-gen-2012 0.23.09 org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleEnd

      INFO: Channel Channel ID c1219afb (outbound) of Remoting connection 6ee0a386 to localhost/127.0.0.1:4447 can no longer process messages

      Exception in thread "main" java.lang.NullPointerException

                at org.jboss.ejb.client.remoting.ChannelAssociation$UnusableChannelResultProducer.getResult(ChannelAssociation.java:323)

                at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:212)

                at org.jboss.ejb.client.remoting.RemotingTransactionInterceptor.handleInvocationResult(RemotingTransactionInterceptor.java:45)

                at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:214)

                at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:51)

                at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:214)

                at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:337)

                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:117)

                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:96)

                at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:86)

                at $Proxy0.add(Unknown Source)

                at org.gmnz.as7.LeRemote.main(LeRemote.java:24)

       

       

      and this one on the server side:

       

      00:23:09,603 ERROR [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "hagakure" task-4) Exception on channel Channel ID 41219afb (inbound)

      of Remoting connection 59e5ffbd to /127.0.0.1:51632 from message org.jboss.remoting3.remote.InboundMessage$3@539530aa: java.io.IOException: Unsupported protocol version 0

              at org.jboss.marshalling.river.RiverUnmarshaller.start(RiverUnmarshaller.java:1184)

              at org.jboss.as.ejb3.remote.protocol.versionone.AbstractMessageHandler.prepareForUnMarshalling(AbstractMessageHandler.java:235)

              at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.processMessage(MethodInvocationMessageHandler.java:101)

              at org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver.handleMessage(VersionOneProtocolChannelReceiver.java:147)

              at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:409) [jboss-remoting-3.2.0.CR8.jar:3.2.0.CR8]

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]

              at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

       

       

      00:23:09,927 ERROR [org.jboss.remoting.remote] (Remoting "hagakure" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host

       

       

      Can't really figure out what's wrong.

       

      Thanks in advance for every hint.

        • 1. Re: JBoss 7 remote JNDI
          jaikiran

          Your client side seems to be using and lower version of remoting jars (CR6) compared to what's there on the server (CR8). Which server version are you trying this against? Make sure you have correct version of all jars on the client side.

          • 2. Re: JBoss 7 remote JNDI
            s3lvatico

            That's right.

            Thanks to your hint I double checked the jar versions.

             

            I actually was deploying the jar with the EJB in a standalone instance of as7.1.CR1b ("flux capacitor"), but the eclipse library I composed was made of the jars coming from another installation of as7.1 (beta1b)... and some of them obviously wrong versions...

             

            My bad. Everything works now, with the correct versions. Thanks

            • 3. Re: JBoss 7 remote JNDI
              s3lvatico

              Just one last thing: although I get the expected results from the remote invocations, is it normal to still have these messages on the server log?

               

              14:21:53,618 ERROR [org.jboss.remoting.remote] (Remoting "hagakure" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host

               

              It looks like something that comes up when the client application exits. Should there be some sort of cleaning up to do before exiting the application?

              • 4. Re: JBoss 7 remote JNDI
                jaikiran

                Simone Monotti wrote:

                 

                Just one last thing: although I get the expected results from the remote invocations, is it normal to still have these messages on the server log?

                 

                14:21:53,618 ERROR [org.jboss.remoting.remote] (Remoting "hagakure" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host

                 

                Windows OS?

                • 5. Re: JBoss 7 remote JNDI
                  s3lvatico

                  yep, win 7 x64

                  • 6. Re: JBoss 7 remote JNDI
                    michaelbini

                    Hi,

                    did you solved this Error ?

                    • 7. Re: JBoss 7 remote JNDI
                      s3lvatico

                      I've carried out some (very simple, very fast) experiments with JBoss 7.1.1, and I didn't get those errors. Also, even with the "old"  7.1.0, those errors didn't seem to be blocking or "nefarious" to any extent - at least for my applications

                      • 8. Re: JBoss 7 remote JNDI
                        jaikiran

                        Yes, this is fixed in 7.1.1.Final.