3 Replies Latest reply on Jan 3, 2007 10:17 AM by vk101

    TransactionRequiredException

      I have a stateless session bean method bound to a user's form submission. That user then proceeds to submit another form that is bound to a stateful session bean method (extended persistence context). Both methods have the default REQUIRED transaction attribute.

      Why might I be getting a TransactionRequiredException in the stateful session bean method (the second method)? How do you propagate transaction contexts between requests as opposed to within the same request?

        • 1. Re: TransactionRequiredException

          You don't ever have a transaction context that spans multiple requests. Those would be separate transactions.

          Can you show the code where you get the error?

          • 2. Re: TransactionRequiredException

            Below is the first class where somebody simply logs in with the login() method.

            @Stateless
            @Name("login")
            public class LoginBean implements Login {
            
             @PersistenceContext(type=TRANSACTION)
             private EntityManager em;
            
             @Out(required=false)
             private Member member;
            
             public String login() {
            
             member = new MemberGetter(em).getMember(loginName);
            
             if (member.getPassword().equals(getPassword())) {
             return "good";
             }
             else {
             return null;
             }
            
             ...
            
            }



            Once they are logged in, let's say they need to add a new name. The problem is that when you add a new name I don't think Member gets injected into the stateful bean from the outjected stateless login() method...

            Does it have anything to do with the transaction attributes, persistence context types, or the fact that I'm going from stateless to stateful calls in one conversation?


            @Stateful
            @Name("change")
            public class ChangeBean implements Change {
            
             @PersistenceContext(type=EXTENDED)
             private EntityManager em;
            
             @In(create=true) @Out(required=false)
             private Member member;
            
             public String addName() {
            
             if (!new ChangeName(em).nameExists(name)) {
             member.getNames().add(name);
             return "good";
             }
             else {
             return null;
             }
            
             ...
            
            }


            • 3. Re: TransactionRequiredException

              I'm not sure if this might have anything to do with it, but in my log I see a lot of "not founds":

              08:13:49,781 DEBUG [Component] seam component not found: org.jboss
              08:13:49,781 DEBUG [Component] seam component not found: org.jboss.seam
              08:13:49,781 DEBUG [Component] seam component not found: org.jboss.seam.core


              However, these also appear on other pages which work completely correctly, as well as this one which isn't working.

              What is the meaning of these messages? Are they to be ignored (after all, their log level is only DEBUG...)