8 Replies Latest reply on Aug 13, 2008 12:03 AM by pmuir

    transaction:no-transaction

      I am trying to build the simplest possible Seam project that I can, I just want a WAR, over Tomcat, with just Seam 2.0.2SP1, no Hibernate (I love it but do not need it for this project). So I commented out this lines:


       <!-- persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                                entity-manager-factory="#{MinimalSeamWebEntityManagerFactory}"/>
      
         <persistence:entity-manager-factory name="MinimalSeamWebEntityManagerFactory" 
                            persistence-unit-name="MinimalSeamWeb"/-->
      



      and disabled transaction management:


       <transaction:no-transaction/>
      



      and now I am getting this infinite loop of stack traces (for this kind of cases it would be nice to have a stop application without stopping app server button) :


      ERROR SeamPhaseListener:120 - uncaught exception
      java.lang.IllegalStateException: Could not start transaction
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:592)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:323)
           at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:140)
           at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
           at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.UnsupportedOperationException: no transaction
           at org.jboss.seam.transaction.NoTransaction.begin(NoTransaction.java:36)
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:587)
           ... 37 more
      11:11:07,671 ERROR SeamPhaseListener:127 - swallowing exception
      
      



      What is wrong? why it doesn't work? Something seems to be calling this method (in org.jboss.seam.transaction.NoTransaction):


      public void begin() throws NotSupportedException, SystemException
         {
            throw new UnsupportedOperationException("no transaction");
         }
      



      Shouldn't it just do nothing, why does it throw this exception? and, if it needs to throw it.. then why does Seam crash? I thought org.jboss.seam.transaction.NoTransaction was for disabling Seam-managed transactions... is it not?


      Regards,


        • 1. Re: transaction:no-transaction
          rogeriobaldini

          Did you solve this problem ?


          Thanks
          Rogerio.

          • 2. Re: transaction:no-transaction

            When (if) I ever solve it, rest assured that I will share my solution :-P.

            • 3. Re: transaction:no-transaction

              I am guessing the answer could be to create my own ReallyNoTransaction class inheriting from org.jboss.seam.transaction.NoTransaction, and overriding all methods to really do nothing.


              Please tell me this isn't true!

              • 4. Re: transaction:no-transaction

                Again, I think this is a really ugly solution, but, it works:


                Create ReallyNoTransaction.java:


                package packageName;
                
                //Lots of other imports here
                import org.jboss.seam.transaction.NoTransaction;
                
                @BypassInterceptors
                public class ReallyNoTransaction extends NoTransaction {
                     
                     public void begin() throws NotSupportedException, SystemException
                        {
                         
                        }
                
                        public void commit() throws RollbackException, HeuristicMixedException,
                                 HeuristicRollbackException, SecurityException, IllegalStateException, SystemException
                        {
                         
                        }
                
                        public int getStatus() throws SystemException
                        {
                           return Status.STATUS_NO_TRANSACTION;
                        }
                
                        public void rollback() throws IllegalStateException, SecurityException, SystemException
                        {
                           
                        }
                
                        public void setRollbackOnly() throws IllegalStateException, SystemException
                        {
                        
                        }
                
                        public void setTransactionTimeout(int timeout) throws SystemException
                        {
                        
                        }
                        
                        @Override
                        public void registerSynchronization(Synchronization sync)
                        {
                        
                        }
                                
                }
                



                And add to components.xml:


                 <component
                  class="packageName.ReallyNoTransaction"
                  name="org.jboss.seam.transaction.transaction" scope="event" precedence="30"/>
                



                And that seems to be it... everything seems to be working (But I wonder if it will show malignant secondary effects later)


                I also wonder why the NoTransaction class that comes with Seam is not implemented as mine? I refuse to believe its only purpose is to crash the application.


                Regards,



                • 5. Re: transaction:no-transaction
                  jguglielmin

                  I've used this before (on previous Seam versions) and you need 2 separate entries in components.xml



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



                          and


                  <transaction:no-transaction />



                  Just one or the other doesn't disable the tx management.

                  • 6. Re: transaction:no-transaction
                    pmuir

                    RTFM - http://docs.jboss.com/seam/2.0.3.CR1/reference/en-US/html/persistence.html#d0e6475. NoTransaction doesn't disable Seam Managed Transactions, and doesn't claim to.

                    • 7. Re: transaction:no-transaction

                      I guess the JBossTools team should also RTFM ;-), because after I use the <core:init transaction-management-enabled="false"/> I get this message in the tree view of editor for components.xml:


                      ERROR: Editor model does not support attribute transaction-management-enabled of core:init|. 
                      



                      I guess it is not that easy to find :-P


                      • 8. Re: transaction:no-transaction
                        pmuir

                        Please report this in the JBIDE JIRA - thanks!