7 Replies Latest reply on Mar 1, 2007 10:18 PM by gavin.king

    Are Seam-managed transactions limited to JSF?

    rmcdonough

      I'm trying utilize a Seam-managed transaction for something other than a JSF component. After read some of the docs and looking at the code, it appears that Seam-managed transactions are limited to JSF. I am trying to marshall a Hibernate object, which is returned from a SessionBean, to XML via JAXB. I am looking for an elegant way of avoiding a LazyInitializationException. Thanks.

      Ryan-

        • 1. Re: Are Seam-managed transactions limited to JSF?
          gavin.king

          So what, precisely, is the client?

          • 2. Re: Are Seam-managed transactions limited to JSF?
            rmcdonough

            The client is Flex, but it could be another HTTP-based client. I have a more long-winded explanation or what I'm trying to d in this post:

            http://jboss.com/index.html?module=bb&op=viewtopic&t=102479

            I'm trying to expose JAXB annotated Entity beans via a RESTful web service. The JAXB-code is living on the web tier at the moment. Some of my services are POJOs, others are Session Beans. My solution to my problems is to start a UserTransaction before the session bean is invoked. I'm new to Seam, but it appears that it may offer a cleaner solution.

            Ryan-

            • 3. Re: Are Seam-managed transactions limited to JSF?
              gavin.king

              OK, so, forget *everything* you know from Spring, etc. :-)

              In Seam and EJB3, persistence context != transaction context.

              So you can have an SFSB with an EJB3 extended persistence context that spans multiple transactions. Or you can have a Seam conversation with a Seam-managed persistence context that spans multiple transactions. None of this is in any way related to JSF or to Seam transaction management.

              I strongly recommend against the idea of spanning an atomic JTA transaction across multiple calls to the server. Instead, use a conversation, and span the conversation across multiple calls.

              • 4. Re: Are Seam-managed transactions limited to JSF?
                rmcdonough

                 

                OK, so, forget *everything* you know from Spring, etc. :-)


                No worries there, not really a fan ;)

                Thanks for clearing this up. One thing I should clarify tho', my transactions don't span multiple HTTP requests, just . In a nut shell, my servlet is calling and EJB that returns a Hibernate entity. The once the entity is returned from the SLSB, the servlet does the unmarshalling.

                So I'm not spanning multiple requests here, I'm just trying to do more stuff to an entity once it has been returned from an EJB. Thanks for your input.

                Ryan-

                • 5. Re: Are Seam-managed transactions limited to JSF?
                  gavin.king

                  Oh OK, in that case, just wrap SeamServletFilter around your servlet, and it will set up a Seam request context that spans the whole HTTP request instead of letting SeamInterceptor make a little request context on each call to the EJB layer.

                  Then the Seam-managed PC will span the whole HTTP request without even the need for a long-running conversation.

                  • 6. Re: Are Seam-managed transactions limited to JSF?
                    rmcdonough

                    Hey Gavin,

                    Thanks a lot for the tips! It took a few trial and errors, but this is working like a champ now and I'm quite happy with the results. Now there's two frameworks to thank you for ;) Seam is freakin' great.

                    Ryan-

                    • 7. Re: Are Seam-managed transactions limited to JSF?
                      gavin.king

                      Cool. Cheers :-)