Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-3816

Return "this" on stateless EJB method looses container transaction management

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Invalid
    • 8.0.8
    • 8.0.10
    • TomEE Build
    • None
    • TomEE 8.0.8, MS Windows 10, OpenJDK 15

    Description

      I experienced the following confusing behaviour in Tomee/OpenEjb when trying to construct a builder pattern with a @stateless session bean. When I return "this" from a builder pattern method, container managed transaction seemst to get lost. E.g a call to an EntityManagers persist() method, will throw a TransactionRequiredException.

      For reproduction figure this ejb (pseudocode):

      @Statelessclass MyEjb {{}@PersistenceContext
      EntityManager em;

      public MyEjb getMe(){

      doSomeInternals();

      return this;

      }

      public void createSomething(){

      em.persist(new SomeEntity());

      }

       

      in some client, if I call:

      myEjb.createSomething()

      the entity is created and stored. However, when I call

      myEjb.getMe().createSomething();

      the TransactionRequiredException is thrown.

       

      Question:

      Is this an intended behavior? (I couln'd find any documentation in EJB why this would not be allowed to do. )

       

       

       

      Attachments

        Activity

          People

            jlmonteiro Jean-Louis Monteiro
            Makkus Makkus B.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: