11 Replies Latest reply on Aug 22, 2011 1:48 PM by Scott Marlow

    No operations allowed after statement closed

    paul.setzermann Newbie

      Hi all,

       

      I'm using AS 7 and am always getting this exception when I try to fill my database.

      I try to persist a lot of objects. After about 8-10 invocations of *.persist() (maybe when the session is flushed) the exception is thrown.

      Any ideas why?  I tried several different approaches but it´s always the same. Do I need something like c3p0?

       

      Cheers, Paul

       

      Exception:

       

      15:15:44,671 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (pool-5-thread-1) SQL Error: 0, SQLState: 08003
      15:15:44,672 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (pool-5-thread-1) No operations allowed after statement closed.
      15:15:44,674 WARN  [com.arjuna.ats.arjuna] (pool-5-thread-1) ARJUNA12125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffffc0a80266:2bc9bcb3:4e300e61:2b, org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization@6ab30eb5 >: javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: No operations allowed after statement closed.
                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1344) [hibernate-entitymanager-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1277) [hibernate-entitymanager-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1283) [hibernate-entitymanager-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1454) [hibernate-entitymanager-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:54) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:97)
                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:274)
                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:94)
                at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:159)
                at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1158)
                at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:119)
                at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
                at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:97)
                at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:279)
                at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:377)
                at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:233)
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:47)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)
                at de.lmu.genzentrum.lafuga.filladb.AdbFiller$$$view10.save(Unknown Source) [classes:]
                at de.lmu.genzentrum.lafuga.filladb.ncbi.NcbiAnnotationFetcher.fetch(NcbiAnnotationFetcher.java:88) [classes:]
                at de.lmu.genzentrum.lafuga.filladb.ncbi.NcbiFillOrUpdate.fill(NcbiFillOrUpdate.java:132) [classes:]
                at de.lmu.genzentrum.lafuga.manager.FillAdbManager.fill(FillAdbManager.java:33) [classes:]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_24]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_24]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_24]
                at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_24]
                at org.jboss.beach.async.DirectInvocationHandler.invoke(DirectInvocationHandler.java:42) [classes:]
                at org.jboss.beach.async.AsyncInvocationHandler$1.call(AsyncInvocationHandler.java:54) [classes:]
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [:1.6.0_24]
                at java.util.concurrent.FutureTask.run(FutureTask.java:138) [:1.6.0_24]
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_24]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_24]
                at java.lang.Thread.run(Thread.java:680) [:1.6.0_24]
      Caused by: org.hibernate.exception.JDBCConnectionException: No operations allowed after statement closed.
                at org.hibernate.exception.internal.SQLStateConverter.convert(SQLStateConverter.java:107) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:131) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:80) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at $Proxy99.setString(Unknown Source)          at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$1.doBind(VarcharTypeDescriptor.java:55) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:80) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:315) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:310) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:55) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2244) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2492) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2931) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:80) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:273) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:265) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:186) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1174) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:399) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:104) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                ... 34 more
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed.
                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [:1.6.0_24]
                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [:1.6.0_24]
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [:1.6.0_24]
                at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [:1.6.0_24]
                at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) [mysql-connector-java-5.1.15.jar:]
                at com.mysql.jdbc.Util.getInstance(Util.java:382) [mysql-connector-java-5.1.15.jar:]
                at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013) [mysql-connector-java-5.1.15.jar:]
                at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) [mysql-connector-java-5.1.15.jar:]
                at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982) [mysql-connector-java-5.1.15.jar:]
                at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927) [mysql-connector-java-5.1.15.jar:]
                at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:402) [mysql-connector-java-5.1.15.jar:]
                at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:4394) [mysql-connector-java-5.1.15.jar:]
                at org.jboss.jca.adapters.jdbc.CachedPreparedStatement.setString(CachedPreparedStatement.java:191)
                at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.setString(WrappedPreparedStatement.java:637)
                at sun.reflect.GeneratedMethodAccessor118.invoke(Unknown Source) [:1.6.0_24]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_24]
                at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_24]
                at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:124) [hibernate-core-4.0.0.Beta1.jar:4.0.0.Beta1]
                ... 53 more
      
      

       

      Source code:

       

      @Stateful
      public class AdbFiller {
        
        @PersistenceContext
                private EntityManager em;
      
                public AdbFiller() {
        
                }
        
      
                public void save(HashSet<ADBGene> genes) {
                          for(ADBGene gene : genes) {
                                    setDBrefs(gene);
                                    em.persist(gene);
                          }
      
                }
      ....