10 Replies Latest reply on Nov 11, 2012 12:26 PM by zdenek.hrib

    Disable Seam managed transactions while using Faces and Security mods.

    bschoen
      How do I turn off seam managed transactions while using faces and security modules? I've tried including components.xml in the WEB-INF folder with:

      <core:init transaction-management-enabled="false"/>
        <transaction:no-transaction/>

      But this does not work. I'd like to go back to having the transaction started at the session bean layer rather than at the start of the jsf request.

      Also, would it be possible to turn the transaction off just for one request or one method call in my backing bean?

      Thanks.
        • 1. Re: Disable Seam managed transactions while using Faces and Security mods.
          lightguard

          Sounds like a Seam 2 question, please ask in that forum.

          • 2. Re: Disable Seam managed transactions while using Faces and Security mods.
            bschoen

            No, it's a Seam 3 question. And now another question? Why did you think this was a Seam 2 question?

            • 3. Re: Disable Seam managed transactions while using Faces and Security mods.
              lightguard

              Because you're using components.xml and that doesn't exist in Seam 3. As to the original question, I'll have to delegate to Brian or Stuart, I don't know.

              • 4. Re: Disable Seam managed transactions while using Faces and Security mods.
                bleathem

                If you want to disable Seam 3 transaction support altogether, just don't include the Seam Persistence jar in your deployment.


                Managing transaction at the view level is doen with the @ViewConfig, I think this is written up in the Faces reference docs.

                • 5. Re: Disable Seam managed transactions while using Faces and Security mods.
                  bschoen

                  If I just remove persistence.jar from the deployment Faces throws an exception because TransactionPhaseListener depends on SeamTransactions. How do I turn of the TransactionPhaseListener in Faces?


                  I'll look into the @ViewConfig docs although I seem to remember them to be very brief.

                  • 6. Re: Disable Seam managed transactions while using Faces and Security mods.
                    fernando_jmt

                    You can do what I've done to solve this issue.

                    • 7. Re: Disable Seam managed transactions while using Faces and Security mods.
                      senti

                      Exactly what I need as well.


                      We use SEAM 3. Weld, Seam Faces, Security. Looks like Security depends on Persistence.


                      When we add Seam Security our conversations do not work because the txns are committed at the end of the REQUESThence Session is closed and throws Exception. How do we stop this commit? If I remove Security conversations work well.


                      [org.jboss.seam.faces.event.PhaseEventBridge]  Fired event [javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@ddeb15]] with qualifiers [[Ljava.lang.annotation.Annotation;@16d5312]
                      [org.jboss.seam.faces.transaction.TransactionPhaseListener]  committing transaction after phase: INVOKE_APPLICATION 5
                      [org.jboss.seam.transaction.UTTransaction]  committing JTA transaction
                      [org.hibernate.event.def.AbstractFlushingEventListener]  processing flush-time cascades
                      [org.hibernate.event.def.AbstractFlushingEventListener]  dirty checking collections
                      [org.hibernate.jdbc.ConnectionManager]  aggressively releasing JDBC connection
                      [com.arjuna.ats.arjuna]  ARJUNA-12141 Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord@125683e
                      [org.jboss.jpa.deployment.ManagedEntityManagerFactory]  ************** closing entity managersession **************
                      



                      I tried Fernando Montaño's Solution, didnt work. Any help would greatly be appreciated.


                      Senti, Australia.

                      • 8. Re: Disable Seam managed transactions while using Faces and Security mods.
                        bschoen
                        It worked for me. Thanks Fernando!

                        Senthil, did you remember to include the dependency for seam-config? This is the module that makes the magic happen. Put seam-beans.xml in .../WEB-INF/classes/META-INF/ folder with the contents below:

                        <?xml version="1.0" encoding="UTF-8"?>
                        <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                               xmlns:s="urn:java:ee" xmlns:t="urn:java:org.jboss.seam.transaction"
                               xmlns:ft="urn:java:org.jboss.seam.faces.transaction"
                               xmlns:sc="urn:java:org.jboss.seam.solder.core"
                               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd">
                            <t:SeSynchronizations>
                                <s:modifies/>
                            </t:SeSynchronizations>
                            <t:UTTransaction>
                                <s:modifies/>
                            </t:UTTransaction>
                            <sc:Veto>
                                <s:Qualifier/>
                            </sc:Veto>
                            <ft:TransactionPhaseListener>
                                <s:replaces/>
                                <sc:Veto/>
                            </ft:TransactionPhaseListener>
                        </beans>
                        • 9. Re: Disable Seam managed transactions while using Faces and Security mods.
                          senti

                          did you remember to include the dependency for seam-config?

                          That did the trick alongwith seam-beans.xml


                          When I didn't include config dependency but included seam-beans.xml, Jboss wasn't complaining, so I thought all is fine but looks like without config, seam-beans.xml config specific entries were ignored.


                          This has been giving me heart-ache for the last week.


                          Thanks Champions Fernando and Brian!  Much appreciate your time and help.

                          • 10. Re: Disable Seam managed transactions while using Faces and Security mods.
                            zdenek.hrib

                            Just a comment for the lucky users of Seam 3.1.0.Final:

                             

                            You should use xmlns:sc="urn:java:org.jboss.solder.core" instead of xmlns:sc="urn:java:org.jboss.seam.solder.core" and of course you have to be aware of the fact, that seam-beans.xml and beans.xml files are NOT processed if stored anywhere in WAR, located inside EAR.

                             

                            Therefore the probably only option to get rid of the exception

                             

                            JBAS010152: APPLICATION ERROR: transaction still active in request with status 0

                             

                            which happens during AJAX request done in RichFaces components is to put all seam*.jar and solder*.jar into the EAR/lib directory, and use the EJB JAR seam-beans.xml for the purpose of disabling the buggy TransactionPhaseListener.

                             

                            In Eclipse/Maven you have to set the seam-faces* dependencies in the WAR pom.xml as "provided", so the seam-faces*.jar will not be twice on the classpath.