1 2 3 Previous Next 36 Replies Latest reply on Nov 29, 2013 10:26 AM by tomjenkinson Go to original post
      • 15. Re: JBoss Transaction not rolling back
        memyself141

        Hello all,

         

        Thanks Tom, but after all this mess, I have decided to not to manage the transactions from our end.... Let the container do it all..

         

        So I wrote my client-side code in an EJB, deployed it on my client JBoss server and access it using the thin-web-app client.

         

        my client side EJBs too are configured as REQUIRED. So the container creates a new Transaction for each call. From this ejb, I am calling the Remote EJB using plain JNDI lookup. This remote EJB too is REQUIRED, so the transaction must propagate to the other server... But it is not.... It is running in its own tx.

         

        I still have not configured the Remote JBoss server to be JTS... (I have raised a request) However, is it really needed??? Because in the link : : Transaction Propagation with JBoss it says "Cases 3 and 4 are only supported if the JTS version of the JBossTS transaction manager is used" My case is Case 2... So do I still need JTS version.. (I ask this only because I don't want to complicate looking up the EJBs and stuff via IIOP if JTS is used)

         

        Any inputs are really appreciated.

        • 16. Re: JBoss Transaction not rolling back
          tomjenkinson

          Hi Aayush,

           

          You need JTS on to propagate the transaction. I think with EAP6.2 there is a proprietary transaction propagation mechanism that doesn't use JTS (but this has some functional limitations). For AS5.1 iirc you have to use JTS.


          Tom

          • 17. Re: JBoss Transaction not rolling back
            memyself141

            Thanks for the quick response Tom. Will go ahead with JTS then And I just hope that I don't need to make any changes to lookup the ejbs (like iiop or orb or CORBA). My current code should just work fine, right??

             

            Also, I read it in AS4.2

            https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/4.2/html/JBoss_Transactions_JTA_Programmers_Guide/chap-Transactions_JTA_Programmers_Guide-Using_JBossJTA_in_Application_Servers.html

            that 'To ensure the transaction context is propagated via JRMP invocations to the server, the transaction propagation context factory needs to be explicitly set for the JRMP invoker proxy. This is done as follows:

            JRMPInvokerProxy.setTPCFactory( new com.arjuna.ats.internal.jbossatx.jts.PropagationContextManager() );'

             

            Do I need to do this in AS5.1 too??? If yes, then where???

             

            Thanks.

            • 18. Re: JBoss Transaction not rolling back
              tomjenkinson

              Unfortunately I suspect you will need to change the lookups to be CORBA ones. I certainly had to for EAP6....

               

              I am not sure what the JRMP stuff was, maybe it was a none-JTS transaction propagation technology available in EAP4?

              • 19. Re: JBoss Transaction not rolling back
                memyself141

                ok. Can't do much then... will update again when my remote server is configured with JTS. thanks.

                • 20. Re: JBoss Transaction not rolling back
                  mmusgrov

                  I came upon this thread where the solution was

                  Currently AS7 doesn't expose UserTransaction via JDNI. Use EJBClient.getUserTransaction() instead.

                  If it doesn't work on AS7 i would expect the same to be true of earlier versions. You could see if that works on AS5. You could create a dummy EJB to do the call and call that from your web tier.

                  • 21. Re: JBoss Transaction not rolling back
                    memyself141

                    Thanks Michael, but I don't think that's the issue as I am able to lookup "UserTransaction" from the POJO client

                     

                    Nonetheless, now I have migrated all my client code to a client-side EJB (CMT). and I am invoking this client-side EJB from a web-app. I am able to pull this through but the Transaction is still not propagated.... Both my client-side EJB and remote EJB have REQUIRED as trans-attribute.

                    As discussed above with Tom, I am trying to turn JTS ON on both the servers.... I guess that is a requirement for CMT Transactions to propagate. I'll need to change my EJB lookup to CORBA though...

                     

                    I am not too sure about changing EJB lookup to CORBA  as I am able to lookup my local EJBs (on the local JBoss with JTS ON) from a POJO client without needing CORBA.... I just hope I don't need CORBA now to worsen my situation

                    • 22. Re: JBoss Transaction not rolling back
                      mmusgrov

                      s

                       

                      Thanks Michael, but I don't think that's the issue as I am able to lookup "UserTransaction" from the POJO client

                       

                      No, the article says you can't do the lookup of "UserTransaction"  from the container in the same way that you do from the POJO. If you are in the container in your webtier then you should use EJBClient.getUserTransaction("remote node").

                      • 23. Re: JBoss Transaction not rolling back
                        memyself141

                        ok. will just test it up in a sample app and update you....

                        • 24. Re: JBoss Transaction not rolling back
                          mmusgrov

                          I think you should be able to call EJBClient.getUserTransaction("remote node") directly from the webtier (ie you won't need to create an ejb for it)

                          • 25. Re: JBoss Transaction not rolling back
                            memyself141

                            just tried that.. Surprisingly, I don't even have org.jboss.ejb.client package in my JBoss5.1. Am I missing something here.... Also here's the link for my stripped-down web-application that gets ServerVMClientUserTransaction instead of ClientUserTransaction. https://community.jboss.org/wiki/ServerVmClientUserTransactionInsteadOfClientUserTransaction

                            (I hope it is not wrong to upload a war file there for this purpose)...


                            have been trying to reply this since an hour but had reached my post-limit....

                            • 26. Re: JBoss Transaction not rolling back
                              mmusgrov

                              In your Demo you have a section that says "Do some transaction work here". Does that involve:

                               

                              1. invoking both remote and local EJBs
                              2. invoking a single remote EJB
                              3. invoking multiple EJBs on the remote server

                               

                              If it is 1 then you need JTS.

                              If it is 2 then you do not need to start a transaction because you said you marked your ejbs with @REQUIRED so the remote server will start the transaction for you

                              But if it is 3 then you do need to get a remote transaction proxy to run multiple calls from your web tier and we need to get to the bottom of why the remote JNDI lookup isn't working for you (as far as I'm aware, the only way you would get an instance of ServerVmClientUserTransaction is if you were doing a local JNDI lookup).

                              • 27. Re: JBoss Transaction not rolling back
                                memyself141

                                Thanks for going through my code...

                                 

                                Initially I tried 3. I invoked 2 remote EJBs which did their work and i rolled back the UserTransaction in case of an error in the second EJB call. But the changes made by the first EJB didn't get rolled back (probably the reason was that I was getting ServerVMClientUserTransaction from context.lookup("UserTransaction") instead of ClientUserTransaction). And I swear to God I am not doing a local JNDI lookup . I used the same context to lookup("UserTransaction") and invoke the EJBs. If this can be solved then my problem is solved for sure....

                                 

                                But that's not today....

                                 

                                So I wrote my this whole client-code in an EJB (REQUIRED), deployed it on my local JBoss as a remote EJB, removed the context.lookup("UserTransaction") and ut.begin() and everything ut related. Now I invoked this  EJB on my local server from the web-tier. As this EJB on the local server too is "REQUIRED" I don't need to start the transaction. The local JBoss container must start it. This EJB in-turn invoked the 2 separate EJBs (both are Remote on the Remote JBoss with "REQUIRED"). Again, even in case of an exception from the second Remote EJB, the changes made by the first EJB are not rolled-back. I guess the reason is that JTS is not ON on my remote JBoss so the transaction started by my client-side EJB didn't propagate to the remote server's EJBs. (I have raised a request to turn JTS ON on the remote JBoss, will update you once it's done).

                                 

                                scenario 2 is working perfectly fine but that doesn't fulfill my purpose... But this does prove that the remote EJBs are configured perfectly fine... just in case...

                                 

                                I guess by scenario 1 what you mean is what I have done right now (All client code in Local EJB which in-turn calls the Remote EJB)... So I hope JTS should do the trick.....

                                • 28. Re: Re: JBoss Transaction not rolling back
                                  tomjenkinson

                                  Based on what I am reading, JTS will do the trick. That being said, it could be a performance optimization to introduce a new single remote EJB that will call both of the existing remote EJBs. Save a network hop.

                                   

                                  PS I will pull your war here and delete your article if you don't mind

                                   

                                  PPS Just mentioning, to attach files to a comment, use the advanced editor and you will see an attach button at the bottom right of the text pane, where before there is just @Mention

                                  • 29. Re: JBoss Transaction not rolling back
                                    memyself141

                                    yes please Tom... Thanks for doing that... I knew that's the wrong place to upload a war file

                                     

                                    so I am waiting for JTS to be turned ON. While it gets done, I was just looking at the base-problem, where it all started...

                                    Getting The ServerVMClientUserTransaction instead of ClientUserTransaction.

                                     

                                    I get ClientUserTransaction from initialContext.lookup("UserTransaction") in a POJO client.

                                    I get ServerVMClientUserTransaction from initialContext.lookup("UserTransaction") in a web-app client.

                                     

                                    The basic difference between a POJO client and a web-app client will be the deployment on the JBoss Server., i.e., POJO client runs independent of any server while the web-app client needs a server (JBoss in my case).

                                     

                                    I am building this web-app in Eclipse so it asks me the Target RunTime while creating the Project and I specify JBoss 5.0 and Eclipse automatically adds all the JBoss5.1\client, JBoss5.1\common\lib, JBoss5.1\lib and JBoss5.1\server\[jts/default]\lib folders and a couple of jars from JBoss5.1\server\[jts/default]\deploy and JBoss5.1\server\[jts/default]\deployers folder.

                                     

                                    While in the POJO client, I manually add all the JARS from the JBoss5.1\client to the Build-path of eclipse.

                                     

                                    So the difference is that I am adding jars from only 1 folder in POJO client while so many others too in web-app client...

                                     

                                    May this be the issue that some additional JAR file makes it return ServerVMClientUserTransaction instead of ClientUserTransaction?