5 Replies Latest reply: Jan 16, 2013 9:49 AM by Jeremy Whiting RSS

    Server tx demarcation from standalone EJB client

    Oscar cs Newbie

      Hello All.

       

      I am trying to to use EJBClient TX suppot in an standalone Java program to call (RMI/JRMP) several methods of stateless EJBs in the same transaction on a remote JBoss AS 7.1 server (standalone.xml profile).

       

      My stateless beans methods are anotated with @TransactionAttribute(MANDATORY) so they won't work unless the client have initiated the transaction.

       

      The client code is as follows:

       

              final Properties props = new Properties();
              props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
              props.put("endpoint.name", "client-endpoint");
              props.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
              props.put("remote.connections", "default");
              props.put("remote.connection.default.host", ip);
              props.put("remote.connection.default.port", Integer.toString(port));
      
              EJBClientConfiguration clientConfiguration = new PropertiesBasedEJBClientConfiguration(props);
              ConfigBasedEJBClientContextSelector selector = new ConfigBasedEJBClientContextSelector(clientConfiguration);
              EJBClientContext.setConstantContext(selector.getCurrent());
      
              final EJBClientTransactionContext localUserTxContext = EJBClientTransactionContext.createLocal();
              EJBClientTransactionContext.setGlobalContext(localUserTxContext);
      
              final StatelessEJBLocator<ITestService.Remote> locator = new StatelessEJBLocator<ITestServiceRemote>(ITestServiceRemote.class, "myApp", "myModule", TestServiceBean.class.getSimpleName(), "");  
              final ITestService.Remote service = EJBClient.createProxy(locator);
      
              // The JBoss server node name is "node"
              UserTransaction tx = EJBClient.getUserTransaction("node");
              tx.begin();        
              service.insertTest(10);
              tx.commit();
      

       

      It doesn't work giving "JBAS014162: Transacción required ...".

       

      My questions are:

       

       

      I have been reading almost all the articles on the wiki and the related many related threads here without finding any clues.

       

      Thanks in advance.

        • 2. Re: Server tx demarcation from standalone EJB client
          Oscar cs Newbie

          Thanks a lot Jaikiran.

           

          As I stated in my previous post, I have been reading all the articles and code about this matter and I knew that testcase.

           

          The problem, I think, is that the test case is Arquillian based so it runs in the same JVM and probably the same classpath as the JBoss instance but my test code is a standalone Java program (no persistence unit or Hibernate or transasaction manager, nothing more that the former code and the jboss-as-ejb-client-bom 7.1.2 dependencies).

           

          Please Jaikiran, let me know if my use case is feasible and what should I check.

          • 3. Re: Server tx demarcation from standalone EJB client
            jaikiran pai Master

            Oscar cs wrote:

             

            Thanks a lot Jaikiran.

             

            As I stated in my previous post, I have been reading all the articles and code about this matter and I knew that testcase.

             

            The problem, I think, is that the test case is Arquillian based so it runs in the same JVM

            It's a @RunAsClient testcase so it doesn't run in the same JVM.

             

             

            Oscar cs wrote:

             

             

            Please Jaikiran, let me know if my use case is feasible and what should I check.

            Which exact version of AS 7.1 is this? Also, please enable org.jboss.ejb.client package level TRACE logs (on client side) and org.jboss.as.ejb3 (on the server side) and post the output here.

            • 4. Re: Server tx demarcation from standalone EJB client
              Oscar cs Newbie

              Thanks Jaikiran.

               

              JBoss AS version is 7.1.3.Final "Arges"

               

              This is the client side log:

               

              2012-12-23 18:09:29,665 [main] DEBUG org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration - endpoint.create.options. has the following options {}

              2012-12-23 18:09:29,666 [main] TRACE org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration - Options {} have been merged with defaults {org.xnio.Options.THREAD_DAEMON=>true} to form {org.xnio.Options.THREAD_DAEMON=>true}

              2012-12-23 18:09:29,667 [main] DEBUG org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration - remote.connectionprovider.create.options. has the following options {org.xnio.Options.SSL_ENABLED=>false}

              2012-12-23 18:09:29,667 [main] TRACE org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration - Options {org.xnio.Options.SSL_ENABLED=>false} have been merged with defaults {} to form {org.xnio.Options.SSL_ENABLED=>false}

              2012-12-23 18:09:29,667 [main] DEBUG org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration - remote.connection.default.connect.options. has the following options {}

              2012-12-23 18:09:29,667 [main] TRACE org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration - Options {} have been merged with defaults {} to form {}

              2012-12-23 18:09:29,669 [main] DEBUG org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration - remote.connection.default.channel.options. has the following options {}

              2012-12-23 18:09:29,669 [main] DEBUG org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration - Connection org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration$RemotingConnectionConfigurationImpl@47393f successfully created for connection named default

              2012-12-23 18:09:29,669 [main] DEBUG org.jboss.ejb.client.PropertiesBasedEJBClientConfiguration - No clusters configured in properties

              2012-12-23 18:09:29,677 [main] DEBUG org.jboss.ejb.client.EJBClientPropertiesLoader - Looking for jboss-ejb-client.properties using classloader sun.misc.Launcher$AppClassLoader@601bb1

              2012-12-23 18:09:29,690 [main] DEBUG org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector - EJB client context org.jboss.ejb.client.EJBClientContext@1b09468 will have no EJB receivers associated with it since there was no EJB client configuration available to create the receivers

              2012-12-23 18:09:30,005 [Remoting "client-endpoint" task-4] DEBUG org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver - Channel Channel ID ca94cc50 (outbound) of Remoting connection 00b60b93 to localhost/127.0.0.1:4447 opened for context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@10d593e, receiver=Remoting connection EJB receiver [connection=Remoting connection <13785d3>,channel=jboss.ejb,nodename=node]} Waiting for version handshake message from server

              2012-12-23 18:09:30,015 [Remoting "client-endpoint" task-1] INFO  org.jboss.ejb.client.remoting - EJBCLIENT000017: Received server version 1 and marshalling strategies [river]

              2012-12-23 18:09:30,025 [Remoting "client-endpoint" task-2] TRACE org.jboss.ejb.client.remoting.ChannelAssociation - Received message with header 0x8

              2012-12-23 18:09:30,025 [main] INFO  org.jboss.ejb.client.remoting - EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@10d593e, receiver=Remoting connection EJB receiver [connection=Remoting connection <13785d3>,channel=jboss.ejb,nodename=node]} on channel Channel ID ca94cc50 (outbound) of Remoting connection 00b60b93 to localhost/127.0.0.1:4447

              2012-12-23 18:09:30,027 [Remoting "client-endpoint" task-2] DEBUG org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver - Received module availability report for 4 modules

              2012-12-23 18:09:30,027 [Remoting "client-endpoint" task-2] DEBUG org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver - Registering module EJBModuleIdentifier{appName='oip.test.app', moduleName='oip.tools.scriptconsole.webapp-0.3.0', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@10d593e, receiver=Remoting connection EJB receiver [connection=Remoting connection <13785d3>,channel=jboss.ejb,nodename=node]}

              2012-12-23 18:09:30,028 [Remoting "client-endpoint" task-2] DEBUG org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver - Registering module EJBModuleIdentifier{appName='oip.test.app', moduleName='oip.transtest.app-0.0.1-SNAPSHOT', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@10d593e, receiver=Remoting connection EJB receiver [connection=Remoting connection <13785d3>,channel=jboss.ejb,nodename=node]}

              2012-12-23 18:09:30,028 [Remoting "client-endpoint" task-2] DEBUG org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver - Registering module EJBModuleIdentifier{appName='oip.test.app', moduleName='oip.transtest.ejb', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@10d593e, receiver=Remoting connection EJB receiver [connection=Remoting connection <13785d3>,channel=jboss.ejb,nodename=node]}

              2012-12-23 18:09:30,028 [Remoting "client-endpoint" task-2] DEBUG org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver - Registering module EJBModuleIdentifier{appName='', moduleName='activemq-rar', distinctName=''} availability for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@10d593e, receiver=Remoting connection EJB receiver [connection=Remoting connection <13785d3>,channel=jboss.ejb,nodename=node]}

              2012-12-23 18:09:30,028 [Remoting "client-endpoint" task-2] TRACE org.jboss.ejb.client.remoting.ChannelAssociation - Received message with header 0xffffffff

              2012-12-23 18:09:30,028 [main] DEBUG org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector - Registered 1 remoting EJB receivers for EJB client context org.jboss.ejb.client.EJBClientContext@10d593e

              2012-12-23 18:09:30,028 [Remoting "client-endpoint" task-2] WARN  org.jboss.ejb.client.remoting.ChannelAssociation - Unsupported message received with header 0xffffffff

              2012-12-23 18:09:30,047 [main] INFO  org.jboss.ejb.client - JBoss EJB Client version 1.0.10.Final

              2012-12-23 18:09:30,214 [Remoting "client-endpoint" task-4] TRACE org.jboss.ejb.client.remoting.ChannelAssociation - Received message with header 0x6

              2012-12-23 18:09:30,215 [Remoting "client-endpoint" task-4] TRACE org.jboss.ejb.client.remoting.ChannelAssociation - Received message with header 0x5

              2012-12-23 18:09:30,216 [Remoting "client-endpoint" task-4] INFO  org.jboss.ejb.client.remoting - EJBCLIENT000011: Discarding result for invocation id 0 since no waiting context found

              2012-12-23 18:09:30,266 [Thread-1] DEBUG org.jboss.ejb.client.remoting.AutoConnectionCloser - Closing Remoting connection <13785d3>

              2012-12-23 18:09:30,269 [Remoting "client-endpoint" task-3] INFO  org.jboss.ejb.client.remoting - EJBCLIENT000016: Channel Channel ID ca94cc50 (outbound) of Remoting connection 00b60b93 to localhost/127.0.0.1:4447 can no longer process messages

              2012-12-23 18:09:30,271 [Thread-1] DEBUG org.jboss.ejb.client.remoting.ChannelAssociation - Closing channel Channel ID ca94cc50 (outbound) of Remoting connection 00b60b93 to localhost/127.0.0.1:4447

              2012-12-23 18:09:30,272 [Thread-1] DEBUG org.jboss.ejb.client.remoting.ChannelAssociation - Registering a re-connect handler org.jboss.ejb.client.remoting.EJBClientContextConnectionReconnectHandler@b1cd0 for broken channel Channel ID ca94cc50 (outbound) of Remoting connection 00b60b93 to localhost/127.0.0.1:4447 in EJB client context org.jboss.ejb.client.EJBClientContext@10d593e

              2012-12-23 18:09:30,272 [Thread-1] DEBUG org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver - Closing channelChannel ID ca94cc50 (outbound) of Remoting connection 00b60b93 to localhost/127.0.0.1:4447

              2012-12-23 18:09:30,275 [Thread-1] DEBUG org.jboss.ejb.client.remoting.AutoConnectionCloser - Closing endpoint "client-endpoint" <68cb6b>

               


              And this is the server side log:


              18:09:24,660 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.3.Final "Arges" started in 7840ms - Started 416 of 506 services (88 services are passive or on-demand)

              18:09:30,002 TRACE [org.jboss.as.ejb3] (Remoting "node" task-3) Welcome Channel ID 4a94cc50 (inbound) of Remoting connection 01913e90 to /127.0.0.1:50700 to the jboss.ejb channel

              18:09:30,019 DEBUG [org.jboss.as.ejb3] (Remoting "node" task-4) Client with protocol version 1 and marshalling strategy river trying to communicate on Channel ID 4a94cc50 (inbound) of Remoting connection 01913e90 to /127.0.0.1:50700

              18:09:30,022 DEBUG [org.jboss.as.ejb3] (Remoting "node" task-4) Sending initial module availability message, containing 4 module(s) to channel Channel ID 4a94cc50 (inbound) of Remoting connection 01913e90 to /127.0.0.1:50700

              18:09:30,023 DEBUG [org.jboss.as.ejb3] (Remoting "node" task-4) Writing out cluster formation message for 0 clusters, to channel Channel ID 4a94cc50 (inbound) of Remoting connection 01913e90 to /127.0.0.1:50700

              18:09:30,117 TRACE [org.jboss.as.ejb3] (Remoting "node" task-1) Got message with header 0x3 on channel Channel ID 4a94cc50 (inbound) of Remoting connection 01913e90 to /127.0.0.1:50700

              18:09:30,182 ERROR [org.jboss.as.ejb3.invocation] (EJB default - 1) JBAS014134: EJB Invocation failed on component TestServiceBean for method public abstract java.lang.Long oip.transtest.ejb.service.ITestService.insert(oip.transtest.ejb.domain.Provider): javax.ejb.EJBTransactionRequiredException: JBAS014162: Transaction is required for invocation org.jboss.invocation.InterceptorContext@138fccc

                        at org.jboss.as.ejb3.tx.CMTTxInterceptor.mandatory(CMTTxInterceptor.java:253) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:182) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                        at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:79) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                        at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:42) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                        at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                        at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:43) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                        at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

                        at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.invokeMethod(MethodInvocationMessageHandler.java:321) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.access$100(MethodInvocationMessageHandler.java:69) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler$1.run(MethodInvocationMessageHandler.java:202) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

                        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [rt.jar:1.6.0_25]

                        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [rt.jar:1.6.0_25]

                        at java.util.concurrent.FutureTask.run(FutureTask.java:138) [rt.jar:1.6.0_25]

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

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

                        at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]

                        at org.jboss.threads.JBossThread.run(JBossThread.java:122)

               

               

              18:09:30,271 DEBUG [org.jboss.as.ejb3] (Remoting "node" read-1) Channel Channel ID 4a94cc50 (inbound) of Remoting connection 01913e90 to /127.0.0.1:50700 closed

              18:09:30,271 TRACE [org.jboss.as.ejb3] (Remoting "node" read-1) channel Channel ID 4a94cc50 (inbound) of Remoting connection 01913e90 to /127.0.0.1:50700 closed


              • 5. Re: Server tx demarcation from standalone EJB client
                Jeremy Whiting Expert

                ConfigBasedEJBClientContextSelector - EJB client context org.jboss.ejb.client.EJBClientContext@1b09468 will have no EJB receivers associated with it since there was no EJB client configuration available to create the receivers

                The error in the log indicates you need to follow these instructions for ejb client.

                 

                client context properties

                 

                Regards,

                Jeremy