4 Replies Latest reply on Mar 19, 2013 3:13 AM by fihu

    EJB 2.1 - transactions

    fihu

      Today I've run into some weird scenario - maybe someone could explain it to me.

       

      Background:

       

       


      SLSB - ASLSB - BEntity Bean with CMR - E
      Transaction attribute declared per classSupportsSupportsSupports

      Transaction attribute declared per method

      Not supportedRequired---

      calls method from bean B

      retrieves information from database using entity bean

       

      Jboss EAP 6.0.1

       

       

      Problem:

      When I run this code on jobss 5 and weblogic it runs just fine, but when I try with jboss 7 I get an exception in method from bean B - "A CMR collection may only be used within the transaction in which it was created". So I investigated the whole situation and it occurred that even though the transaction attribute for beans B method is "required" there was no transaction inside it. When I change transaction type to "RequiresNew" everything worked fine.

       

      1. Am I getting transactions type mixed up or is it a bug in jboss?

      2.  Is it necessary to open a transaction to retrieve entity bean (one that uses CMR) from database?

        • 1. Re: EJB 2.1 - transactions
          robert.panzer

          Hi,

           

          Does the method of SLSB B contain arrays in the parameter list?

          If so this might be the same problem that I have reported:

          https://issues.jboss.org/browse/AS7-6724

           

          Kind regards

          Robert

          • 2. Re: EJB 2.1 - transactions
            fihu

            hello, thank you for your response. Unfortunately this is not the case here (methods take long as an argument).

            • 3. Re: EJB 2.1 - transactions
              wdfink

              It is necessary to have a transaction if you access an Entity.

              If you use the Entity and later iterate the CMR both must be in the same transaction context.

               

              Also it will have a better performance if you open and keep the Tx within the SLSB (I annotate the Entities always with MANDATORY)

               

              From the Tx annotations it looks like you have found a bug.

              If the Class annotation is 'Supports' the method annotation 'Required' will not respected.

               

              But if the Class annotation is 'Required' the method annotation is 'Supports' it worked.

               

              So the workaround is to use the class annotation 'Required' and set other attributes at method level as needed.

               

              Please file a JIRA bug.

              • 4. Re: EJB 2.1 - transactions
                fihu

                Thank you for the response. I've filled jira bug - https://issues.jboss.org/browse/AS7-6749