1 Reply Latest reply on Mar 16, 2009 4:50 AM by Troy Sellers

    Integration test fails, trying to set autocommit during managed transaction

    Troy Sellers Newbie

      Hi All,


      I have implemented an integration test, pretty much exactly the same as described in chapter 35 of the 2.1.1.GA documentation.


      When I run this I get java.sql.SQLException: You cannot set autocommit during a managed transaction!


      I am not trying to set auto-commit anywhere, not sure what is.
      The error is thrown when trying to set values in the updateModelValues() method.


      Seam 2.1.1GA
      JBoss Embedded Beta 3.SP3
      Maven 2.0.9



      public class TestLoginWithFacesMessages extends SeamTest {
           
              
              @Test
              public void testUiLoginInteractions() throws Exception {
                   
                   new FacesRequest() {
                        
                        @Override
                        protected void processValidations() {
                             System.out.println("Over ride validation processing");
                        }
                        
                        @Override
                        protected void updateModelValues() throws Exception {
                             System.out.println("setting model values");
                             setValue("#{identity.username}", "Troy");
                             setValue("#{identity.password", "password");
                             System.out.println("set all values");
                        }
                        
                        @Override
                        protected void invokeApplication () {
                             System.out.println("invoking login method");
                             invokeMethod("#{identity.login}");
                             System.out.println("have invoked method");
                        }
                        
                        @Override
                        protected void renderResponse() {
                             System.out.println("rendering response");
                             Iterator<FacesMessage> messages = FacesContext.getCurrentInstance().getMessages();
                             assert messages.hasNext();
                             assert messages.next().getSummary().equals("Welcome Troy");
                             assert !messages.hasNext();
                             System.out.println("rendered...");
                        }
                        
                   }.run();
                   
              }
      }
      




      Over ride validation processing
      setting model values
      INFO  [org.hibernate.impl.SessionFactoryImpl] closing
      INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] Running hbm2ddl schema export
      INFO  [org.hibernate.tool.hbm2ddl.SchemaExport] exporting generated schema to database
      ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] schema export unsuccessful
      java.sql.SQLException: You cannot set autocommit during a managed transaction!
           at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:549)
           at org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:328)
           at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:36)
           at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:180)
           at org.hibernate.tool.hbm2ddl.SchemaExport.drop(SchemaExport.java:143)
           at org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:810)
           at org.hibernate.ejb.EntityManagerFactoryImpl.close(EntityManagerFactoryImpl.java:46)
           at org.jboss.seam.persistence.EntityManagerFactory.shutdown(EntityManagerFactory.java:58)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2211)
           at org.jboss.seam.Component.callDestroyMethod(Component.java:2142)
           at org.jboss.seam.Component.destroy(Component.java:1436)
           at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:251)
           at org.jboss.seam.contexts.Lifecycle.endApplication(Lifecycle.java:56)
           at org.jboss.seam.contexts.ServletLifecycle.endApplication(ServletLifecycle.java:135)
           at org.jboss.seam.mock.AbstractSeamTest.stopSeam(AbstractSeamTest.java:938)
           at org.jboss.seam.mock.SeamTest.stopSeam(SeamTest.java:65)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
           at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:398)
           at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
           at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:82)
           at org.testng.SuiteRunner.privateRun(SuiteRunner.java:309)
           at org.testng.SuiteRunner.run(SuiteRunner.java:198)
           at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:821)
           at org.testng.TestNG.runSuitesLocally(TestNG.java:788)
           at org.testng.TestNG.run(TestNG.java:708)
           at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62)
           at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141)
           at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
           at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
      testing junit test setup
      Tests run: 6, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 14.077 sec <<< FAILURE!
      



      Any ideas? I am stumped...


      Cheers,
      Troy