8 Replies Latest reply on Apr 8, 2014 3:00 PM by jgurda

    EJB3.1 remote look up using jboss 7.1.1

    alif

      Hi I have deployed ejbs remote session beans in jboss 7.1.1 .It looks as follows


      java:global/TCPro/Domain/EnterpriseServiceSessionBean!com.ingenix.transact.domain.enterprise.interfaces.EnterpriseManager
      java:app/Domain/EnterpriseServiceSessionBean!com.ingenix.transact.domain.enterprise.interfaces.EnterpriseManager
      java:module/EnterpriseServiceSessionBean!com.ingenix.transact.domain.enterprise.interfaces.EnterpriseManager
      java:jboss/exported/TCPro/Domain/EnterpriseServiceSessionBean!com.ingenix.transact.domain.enterprise.interfaces.EnterpriseManager
      java:global/TCPro/Domain/EnterpriseServiceSessionBean
      java:app/Domain/EnterpriseServiceSessionBean
      java:module/EnterpriseServiceSessionBean

      I have written EJB client project to lookup remote ejbs.
      Properties jndiProperties = new Properties();
      jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
          jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
          jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");
          jndiProperties.put("jboss.naming.client.ejb.context", true);
          jndiProperties.put(Context.SECURITY_PRINCIPAL, "root123");
          jndiProperties.put(Context.SECURITY_CREDENTIALS, "password123");
      InitialContext ctx = new InitialContext(jndiProperties);
      Object  mObject= ctx.lookup("ejb:TCPro/Domain//EnterpriseServiceSessionBean!com.ingenix.transact.domain.enterprise.interfaces.EnterpriseManager");
      EnterpriseManager enterpriseManager=(EnterpriseManager)mObject;
      Upto here look up is success full. But if I acees any Ejb methods for example enterpriseManager.save(EnterPriseDTO) it is giving following exception.

        ERROR [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "lh7u0cnu3379btz" task-4) Exception on channel Channel ID 288519a1 (inbound) of Remoting connection 50dc73bd to /127.0.0.1:50090 from message org.jboss.remoting3.remote.InboundMessage$3@36b355be: java.io.EOFException: Read past end of file
      at org.jboss.marshalling.SimpleDataInput.eofOnRead(SimpleDataInput.java:126) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
      at org.jboss.marshalling.SimpleDataInput.readUnsignedByteDirect(SimpleDataInput.java:263) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
      at org.jboss.marshalling.SimpleDataInput.readUnsignedByte(SimpleDataInput.java:224) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
      at org.jboss.marshalling.river.RiverUnmarshaller.start(RiverUnmarshaller.java:1186)
      at org.jboss.as.ejb3.remote.protocol.versionone.AbstractMessageHandler.prepareForUnMarshalling(AbstractMessageHandler.java:240)
      at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.processMessage(MethodInvocationMessageHandler.java:104)
      at org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver.handleMessage(VersionOneProtocolChannelReceiver.java:170)
      at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:437) [jboss-remoting-3.2.3.GA.jar:3.2.3.GA]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
      at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]



      Not that I have put Jboss7.1.1home/bin /client/jboss-client jar in my client project.
      I also tried putting below jars..but still getting the same exception


      \jboss-as-7.1.1.Final\modules\org\jboss\ejb-client\main\jboss-ejb-client-1.0.5.Final.jar
      ..\jboss-as-7.1.1.Final\modules\org\jboss\ejb3\main\jboss-ejb3-ext-api-2.0.0.jar
      ..\jboss-as-7.1.1.Final\modules\org\jboss\logging\main\jboss-logging-3.1.0.GA.jar
      ..\jboss-as-7.1.1.Final\modules\org\jboss\xnio\main\xnio-api-3.0.3.GA.jar
      ..\jboss-as-7.1.1.Final\modules\org\jboss\sasl\main\jboss-sasl-1.0.0.Final.jar
      ..\jboss-as-7.1.1.Final\modules\org\jboss\marshalling\river\main\jboss-marshalling-river-1.3.11.GA.jar
      ..\jboss-as-7.1.1.Final\modules\org\jboss\marshalling\main\jboss-marshalling-1.3.11.GA.jar
      ..\jboss-as-7.1.1.Final\modules\javax\ejb\api\main\jboss-ejb-api_3.1_spec-1.0.1.Final.jar
      ..\jboss-as-7.1.1.Final\modules\org\jboss\remoting3\main\jboss-remoting-3.2.3.GA.jar
      ..\jboss-as-7.1.1.Final\modules\org\jboss\xnio\nio\main\xnio-nio-3.0.3.GA.jar
      ..\jboss-as-7.1.1.Final\modules\javax\transaction\api\main\jboss-transaction-api_1.1_spec-1.0.0.Final.jar

      Please help .

      Thanks in advance,
      Fakaruddin

        • 1. Re: EJB3.1 remote look up using jboss 7.1.1
          wdfink

          You should not set "Context.URL_PKG_PREFIXES" in your InitialContext, this is a property used for the ejb-client api and NOT for the remote-naming approach.

          • 2. Re: EJB3.1 remote look up using jboss 7.1.1
            alif

            Hi Thanks for replying.

            After removing Context.URL_PKG_PREFIXES", Not able to look up remote ejb.

            Its getting the exception:

            javax.naming.NameNotFoundException: ejb:TCPro/Domain/EnterpriseServiceSessionBean!com.ingenix.transact.domain.enterprise.interfaces.EnterpriseManager -- service jboss.naming.context.java.jboss.exported.ejb:TCPro.Domain."EnterpriseServiceSessionBean!com.ingenix.transact.domain.enterprise.interfaces.EnterpriseManager"

             

             

            If I include Context.URL_PKG_PREFIXES look up is sucessful, but not able to execute any function of EnterpriseManager.

             

            Thanks.

            Fakaruddin

            • 3. Re: EJB3.1 remote look up using jboss 7.1.1
              wdfink

              In that you have one more point with mixed up settings.

               

              If you use "remote://..." you must not use "ejb:" for lookup.

              If you use the URL_PKG_PREFIX this is the only property for the InitialContext and you need to have a jboss-ejb-client.properties file, or even use the Ejb-Client API, to setup the connections. Only in this case you need to have the "ejb:" lookup prefix.

               

              The reason why you see the failure during invocation and not for the lookup is that the client is optimized and did not call the server for the lookup, the only action is that the proxy-class is instantiated. The only failure reason for the lookup is that the Interface is not available or the proxy class can not be instantiated.

              • 4. Re: EJB3.1 remote look up using jboss 7.1.1
                alif

                Hi Thanks for your reply.

                Now I am using..like

                 

                 

                    jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                    jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");

                     jndiProperties.put(Context.SECURITY_PRINCIPAL, "root123");

                    jndiProperties.put(Context.SECURITY_CREDENTIALS, "password123");

                InitialContext ctx = new InitialContext(jndiProperties);

                ctx.lookup("TCPro/Domain/EnterpriseServiceSessionBean!com.ingenix.transact.domain.enterprise.interfaces.EnterpriseManager") look up is working fyn.

                but agian I am accesseing any function of  EnterpriseManager getting the same exception

                ERROR [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "lh7u0cnu3379btz" task-4) Exception on channel Channel ID 288519a1 (inbound) of Remoting connection 50dc73bd to /127.0.0.1:50090 from message org.jboss.remoting3.remote.InboundMessage$3@36b355be

                 

                 

                Please help

                 

                • 5. Re: EJB3.1 remote look up using jboss 7.1.1
                  wdfink

                  I don't have an idea what happen and how your app look like.

                  Do you have a simple example to reproduce the issue?

                   

                  You might find helpful examples in my repository

                  wfink/jboss-as-quickstart at ejb-client

                  You may use ejb-multi-server (as server side application)

                  and the ejb-clients/remote-naming/* for the client side examples

                  • 6. Re: Re: EJB3.1 remote look up using jboss 7.1.1
                    alif

                    Wolf thanks for your reply

                     

                    I am trying to look up connection factory from jboss client.

                    Properties jndiProperties = new Properties();

                    final Properties env = new Properties();

                    env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                    env.put(Context.PROVIDER_URL, "remote://localhost:4447");

                    env.put(Context.SECURITY_PRINCIPAL, "admin");

                    env.put(Context.SECURITY_CREDENTIALS, "admin123");

                    Context context = new InitialContext(env);

                     

                    I tried for look up as below

                     

                    objRef=context.lookup("jms/RemoteConnectionFactory");

                     

                    getting the following exception

                     

                    javax.naming.NamingException: Unable to invoke lookup, status=WAITING


                    My stanadlone.xml file is as

                     

                    <jms-connection-factories>

                                        <connection-factory name="InVmConnectionFactory">

                                            <connectors>

                                                <connector-ref connector-name="in-vm"/>

                                            </connectors>

                                            <entries>

                                                <entry name="java:/ConnectionFactory"/>

                                            </entries>

                                        </connection-factory>

                                        <connection-factory name="RemoteConnectionFactory">

                                            <connectors>

                                                <connector-ref connector-name="netty"/>

                                            </connectors>

                                            <entries>

                                                <entry name="RemoteConnectionFactory"/>

                                                <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>

                                            </entries>

                                        </connection-factory>

                                        <pooled-connection-factory name="hornetq-ra">

                                            <transaction mode="xa"/>

                                            <connectors>

                                                <connector-ref connector-name="in-vm"/>

                                            </connectors>

                                            <entries>

                                                <entry name="java:/JmsXA"/>

                                            </entries>

                                        </pooled-connection-factory>

                             </jms-connection-factories>

                     

                     

                    I need  to push message to MDB deployed in Jboss 7.1.1  and from stanadlone client need to push jms queue.

                    Please help.

                    Thanks,

                    Fakaruddin .

                    • 7. Re: EJB3.1 remote look up using jboss 7.1.1
                      wdfink

                      You might have a look to the JMS quickstart https://github.com/jboss-developer/jboss-eap-quickstarts/tree/6.3.x-develop/helloworld-jms

                      You may have the user or ports configured wrong.

                      • 8. Re: EJB3.1 remote look up using jboss 7.1.1
                        jgurda

                        Ali,

                         

                        I had simillar problem:

                        20:12:17,378 ERROR [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "laptop" task-4) Exception on channel Channel ID 2cbd496e (inbound) of Remoting connection 009bafba to /127.0.0.1:51519 from message org.jboss.remoting3.remote.InboundMessage$3@403992: java.io.EOFException: Read past end of file
                            at org.jboss.marshalling.SimpleDataInput.eofOnRead(SimpleDataInput.java:126) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
                            at org.jboss.marshalling.SimpleDataInput.readUnsignedByteDirect(SimpleDataInput.java:263) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
                            at org.jboss.marshalling.SimpleDataInput.readUnsignedByte(SimpleDataInput.java:224) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
                            at org.jboss.marshalling.river.RiverUnmarshaller.doReadClassDescriptor(RiverUnmarshaller.java:902)
                            at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1204)
                            at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
                            at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
                            at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37) [jboss-marshalling-1.3.11.GA.jar:1.3.11.GA]
                            at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.processMessage(MethodInvocationMessageHandler.java:156)
                            at org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver.handleMessage(VersionOneProtocolChannelReceiver.java:170) 
                        

                         

                        My problem was one of Remote EJB's input parameters which was not Serializable. Oddly JBoss logs didn't show that explicitly. I got clue by realizing that some stack trace elements are from file "jboss-marshalling-1.3.11.GA.jar:1.3.11.GA"

                         

                        Thanks,

                        Jan