3 Replies Latest reply on Nov 28, 2007 9:01 AM by breako

    JBoss Seam JTA transactions

    breako

      Hi,
      Seam can be used without EJB.
      I was just looking through the examples that come with Seam and in the jpa example I saw that the persistence unit transaction type was set to "RESOURCE_LOCAL". My question is it possible to configure a Seam managed entity manager to use JTA?
      I assume it is just a matter of changing the transaction type to JTA?
      Thanks

        • 1. Re: JBoss Seam JTA transactions
          breako

           

          "breako" wrote:
          Hi,
          Seam can be used without EJB.
          I was just looking through the examples that come with Seam and in the jpa example I saw that the persistence unit transaction type was set to "RESOURCE_LOCAL". My question is it possible to configure a Seam managed entity manager to use JTA?
          I assume it is just a matter of changing the transaction type to JTA?
          Thanks


          an update on this.
          I try to update the JPA example as described to use JTA.

          I get
          java.lang.IllegalStateException: Could not start transaction
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:571)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:307)
           at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:142)
           at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:116)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
          



          I think this may be the bug described at

          http://jira.jboss.com/jira/browse/JBSEAM-2053

          But, I checked my richfaces jars and they are 3.1.2 GA so they should have that fix?

          any ideas why I am getting this?

          Thanks


          • 2. Re: JBoss Seam JTA transactions
            pmuir

            You tell JPA which transaction type to use (by default JTA) in persistence.xml. You also need to tell Seam which transaction type to use in components.xml so you probably forgot to edit components.xml

            • 3. Re: JBoss Seam JTA transactions
              breako

              Thanks for that - it makes sens as my components.xml had an entry

              <transaction:entity-transaction entity-manager="#{em}"/>
              

              I remove this line and all works fine.
              Just to let people know my components.xml is

              <?xml version="1.0" encoding="UTF-8"?>
              <components xmlns="http://jboss.com/products/seam/components"
               xmlns:core="http://jboss.com/products/seam/core"
               xmlns:persistence="http://jboss.com/products/seam/persistence"
               xmlns:transaction="http://jboss.com/products/seam/transaction"
               xmlns:security="http://jboss.com/products/seam/security"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation=
               "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
               http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
               http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
               http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
               http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
              
               <core:manager conversation-timeout="120000"
               concurrent-request-timeout="500"
               conversation-id-parameter="cid"/>
              
              
               <persistence:entity-manager-factory name="bookingDatabase"/>
              
               <persistence:managed-persistence-context name="em"
               auto-create="true"
               entity-manager-factory="#{bookingDatabase}"/>
               <security:identity authenticate-method="#{authenticator.authenticate}"/>
              
              </components>
              

              Enjoy.

              My next challenge is to get Seam working with JTA in Tomcat! I might take questions in a separate thread :-)