5 Replies Latest reply on Aug 22, 2006 2:06 PM by Pavel Rubin

    Container will hang when persisting a large number of object

    Jacob Boje Newbie

      HI,

      Our JBOSS EJB3 container (4.0.3SP1) is hanging in a few minutes followed by a timeout, when I try to persist and flush a large number of objects (actually only about 1500 objects) objects in one transaction. The overall exception is

      Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=WMLI011810/744, BranchQual=, localId=744]

      In a statefull session bean an object A is created. Afterwards about 1000 entries of another object B are added to a collection in object A - these B-objects needs to be persisted when object A is persisted. The operation em.persist(A) takes about one minute to complete - that's ok in this situation. So far no problems...

      Now, when the sessionbean is doing a em.flush() or returning control back to the container (after last statement in the method is succefully complated), the container is hanging for about 3 minutes before a timeout is thrown. The JBOSS java.exe process is using 100% cpu power.
      Why should is take so long time and so many resources to flush/commit only a few thousand objects?

      If I'm reducing the B objects to about 50 og 100 then anything works nice. Isn't JBOSS scaled for large transactions?

      Can anyone help us with this problem?


      --- stacktrace (just a small top-part)

      15:31:13,843 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=WMLI011810/744, BranchQu
      al=, localId=744] timed out. status=STATUS_ACTIVE
      15:33:52,225 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null
      15:33:52,225 ERROR [JDBCExceptionReporter] Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=
      WMLI011810/744, BranchQual=, localId=744]; - nested throwable: (javax.resource.ResourceException: Transaction is not act
      ive: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=WMLI011810/744, BranchQual=, localId=744])
      15:33:52,225 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.exception.GenericJDBCException: Cannot open connection
      at org.hibernate.JDBCException.(JDBCException.java:25)
      ....... AND A LOT MORE ....

        • 1. Re: Container will hang when persisting a large number of ob
          Emmanuel Bernard Master

          hard to say, you don't give a lot of info.
          We've made some flush() speed progress though in this area in the latest version.

          • 2. Re: Container will hang when persisting a large number of ob
            Jacob Boje Newbie

            OK, I'll try to paste some of the entity objetcs code to this thread.

            Check out the Company and BranchPO below. All getter and setters omitted.

            We're using a webservice to fill-out CompanyPO with information. Som companies have more then 700 branches, which all are aded to the branches collection of CompanyPO.

            After finishing the company with all the branches, address etc. the company entity is persisted, if all rules is passed.
            The persists operation completes succesfully after about half a secondf, but when we then are doing a flush operation on the entitymanager the container will hang and after a while a timeout is thrown.

            Maybe a solution is to perstist and flush more often, which shouldn't be neccesary with the relative small data amount. But, I'll give it try anyway.

            If you need more information please tell me which.

            ----- Source code ----


            ** CompanyPO **
            Id column is inherited.

            public class CompanyPO extends RegisteredEntityPO implements Serializable {

            @Column(name = "CVR_NO", unique = true, nullable=false)
            private String cvrNo;

            @OneToMany(mappedBy = "company", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
            private Collection branches;

            @ManyToMany(fetch=FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
            @JoinTable(table = @Table(name = "HV_COMPANY_MANAGERS")
            ,joinColumns = {@JoinColumn(name="COMPANY_ID")}
            ,inverseJoinColumns = {@JoinColumn(name="MANAGER_ID")}
            )
            private Collection managerList;
            //@Transient
            //private Collection managerList = new ArrayList();

            @ManyToMany(fetch=FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST})
            @JoinTable(table = @Table(name = "HV_COMPANY_OWNERS")
            ,joinColumns = {@JoinColumn(name="COMPANY_ID")}
            ,inverseJoinColumns = {@JoinColumn(name="OWNER_ID")}
            )
            private Collection ownerList;

            @ManyToOne(optional=true)
            private AgentPO agentFor;
            }

            ** Branch PO **

            @Entity(access=AccessType.FIELD)
            @Table(name = "HV_BRANCH")
            @SequenceGenerator(name="BRAN_SEQ_GEN", sequenceName="HV_BRAN_SEQ",allocationSize=1)
            public class BranchPO implements StateObject, Serializable {

            @Id (generate=GeneratorType.SEQUENCE,generator="BRAN_SEQ_GEN")
            private int id;

            @Column(name="P_NO")
            private String pNo;

            private String name;

            @ManyToOne(optional = false, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
            private CompanyPO company;

            @OneToOne(optional=false, cascade={CascadeType.PERSIST, CascadeType.MERGE})
            @JoinColumn(name="ADDR_ID", unique=false, nullable=false)
            private AddressPO address;

            @OneToOne(optional=true, cascade={CascadeType.PERSIST, CascadeType.MERGE})
            @JoinColumn(name="MANAGER_ID", unique=false)
            private BranchManagerPO manager;

            @Column(name="IS_JOINED")
            private boolean joined;

            @ManyToOne(optional=true, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
            @JoinColumn(name="SHIS_ID")
            private StatusHistoryPO currentStatus;

            @OneToMany(mappedBy="branch", fetch=FetchType.LAZY)
            private Collection statusHistory;
            }

            • 3. Re: Container will hang when persisting a large number of ob
              Jacob Boje Newbie

              ...and here is the complete stacktrace....

              10:43:35,338 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=WMLI011810/1509, BranchQ
              ual=, localId=1509] timed out. status=STATUS_ACTIVE
              10:45:26,458 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null
              10:45:26,458 ERROR [JDBCExceptionReporter] Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=
              WMLI011810/1509, BranchQual=, localId=1509]; - nested throwable: (javax.resource.ResourceException: Transaction is not a
              ctive: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=WMLI011810/1509, BranchQual=, localId=1509])
              10:45:26,468 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
              org.hibernate.exception.GenericJDBCException: Cannot open connection
              at org.hibernate.JDBCException.(JDBCException.java:25)
              at org.hibernate.exception.GenericJDBCException.(GenericJDBCException.java:19)
              at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
              at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
              at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
              at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
              at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:307)
              at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:109)
              at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
              at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
              at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:169)
              at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2047)
              at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2426)
              at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
              at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
              at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
              at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
              at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:29
              6)
              at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
              at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905)
              at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:185)
              at org.jboss.ejb3.entity.InjectedEntityManager.flush(InjectedEntityManager.java:122)
              at com.wmdata.hvidvask.appservices.EntityStatusChange.changeAndMerge(EntityStatusChange.java:94)
              at com.wmdata.hvidvask.appservices.CompanyAppService.RegisterCompany(CompanyAppService.java:54)
              at com.wmdata.hvidvask.facade.CompanyRegistrationSFSB.approveRegistration(CompanyRegistrationSFSB.java:524)
              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.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
              at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropa
              gationInterceptor.java:44)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:133)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:136)
              at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:83)
              at $Proxy97.approveRegistration(Unknown Source)
              at com.wmdata.hvidvask.presentation.action.editCompany.EditCompanyReceiptAction.execute(EditCompanyReceiptAction
              .java:47)
              at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
              at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
              at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
              at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at com.wmdata.hvidvask.presentation.filter.SessionFilter.doFilter(SessionFilter.java:75)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at com.wmdata.hvidvask.presentation.security.TicketFilter.doFilter(TicketFilter.java:164)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at com.wmdata.hvidvask.presentation.filter.ContextFilter.doFilter(ContextFilter.java:45)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
              at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
              at java.lang.Thread.run(Thread.java:595)
              Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, Global
              Id=WMLI011810/1509, BranchQual=, localId=1509]; - nested throwable: (javax.resource.ResourceException: Transaction is no
              t active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=WMLI011810/1509, BranchQual=, localId=1509])
              at org.jboss.util.NestedSQLException.(NestedSQLException.java:62)
              at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:79)
              at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
              at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:304)
              ... 78 more
              Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalI
              d=WMLI011810/1509, BranchQual=, localId=1509]
              at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:331)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:46
              2)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseCon
              nectionManager2.java:894)
              at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:73)
              ... 80 more
              10:46:03,531 INFO [STDOUT] org.hibernate.exception.GenericJDBCException: Cannot open connection
              10:46:03,531 INFO [STDOUT] at com.wmdata.hvidvask.facade.CompanyRegistrationSFSB.approveRegistration(CompanyRegistr
              ationSFSB.java:551)
              10:46:03,531 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              10:46:03,531 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              10:46:03,531 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

              10:46:03,531 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
              10:46:03,531 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
              10:46:03,531 INFO [STDOUT] at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(Extende
              dPersistenceContextPropagationInterceptor.java:44)
              10:46:03,531 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              10:46:03,531 INFO [STDOUT] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:
              32)
              10:46:03,541 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              10:46:03,541 INFO [STDOUT] at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceIntercepto
              r.java:133)
              10:46:03,541 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              10:46:03,541 INFO [STDOUT] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
              10:46:03,541 INFO [STDOUT] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
              10:46:03,541 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              10:46:03,541 INFO [STDOUT] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61
              )
              10:46:03,541 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              10:46:03,541 INFO [STDOUT] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor
              .java:63)
              10:46:03,541 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              10:46:03,541 INFO [STDOUT] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
              10:46:03,541 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              10:46:03,541 INFO [STDOUT] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.ja
              va:91)
              10:46:03,541 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
              10:46:03,541 INFO [STDOUT] at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:136)
              10:46:03,541 INFO [STDOUT] at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:83)
              10:46:03,541 INFO [STDOUT] at $Proxy97.approveRegistration(Unknown Source)
              10:46:03,541 INFO [STDOUT] at com.wmdata.hvidvask.presentation.action.editCompany.EditCompanyReceiptAction.execute(
              EditCompanyReceiptAction.java:47)
              10:46:03,541 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:
              484)
              10:46:03,541 INFO [STDOUT] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
              10:46:03,541 INFO [STDOUT] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
              10:46:03,541 INFO [STDOUT] at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
              10:46:03,541 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              10:46:03,541 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterCha
              in.java:252)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
              173)
              10:46:03,541 INFO [STDOUT] at com.wmdata.hvidvask.presentation.filter.SessionFilter.doFilter(SessionFilter.java:75)

              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterCha
              in.java:202)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
              173)
              10:46:03,541 INFO [STDOUT] at com.wmdata.hvidvask.presentation.security.TicketFilter.doFilter(TicketFilter.java:164
              )
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterCha
              in.java:202)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
              173)
              10:46:03,541 INFO [STDOUT] at com.wmdata.hvidvask.presentation.filter.ContextFilter.doFilter(ContextFilter.java:45)

              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterCha
              in.java:202)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
              173)
              10:46:03,541 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterCha
              in.java:202)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
              173)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              10:46:03,541 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:3
              9)
              10:46:03,541 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValv
              e.java:159)
              10:46:03,541 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              10:46:03,541 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              10:46:03,541 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
              10:46:03,541 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Htt
              p11Protocol.java:744)
              10:46:03,541 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              10:46:03,541 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:1
              12)
              10:46:03,541 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)

              • 4. Re: Container will hang when persisting a large number of ob
                Novice

                "Can not open connection" sounds like the pool is exhausted. Do you have a connection leak? Check the jca pool MBeans.

                Another thought is, that you may have DB locks that block a transaction. What DB is it?

                • 5. Re: Container will hang when persisting a large number of ob
                  Pavel Rubin Newbie

                  I have a simmilar problem... I'm inserting about 12 000 Entities in the DB, and after about 8000 it craches thithe the same "Cannot open connection" exception.

                  The problem is, that connection is obtained and released for each call to persist(). See hibernate log:

                  2006-08-22 21:50:44,889 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
                  2006-08-22 21:50:44,889 DEBUG [org.hibernate.SQL] insert into Team (razdel, kod) values (?, ?)
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 15842
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 2)
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 1) (open ResultSets: 0, globally: 0)]
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 1)
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.SQL] insert into TeamName (team_id, lang, name) values (?, ?, ?)
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 31683
                  2006-08-22 21:50:44,905 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 2)
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 1) (open ResultSets: 0, globally: 0)]
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 1)
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.SQL] insert into TeamName (team_id, lang, name) values (?, ?, ?)
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 31684
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 2)
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 1) (open ResultSets: 0, globally: 0)]
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 1)
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
                  2006-08-22 21:50:44,920 DEBUG [org.hibernate.SQL] insert into Team (razdel, kod) values (?, ?)
                  2006-08-22 21:50:44,936 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 15843

                  I think there is also perfomance problem here, but don't know how to avoid this.
                  More info here: http://forum.hibernate.org/viewtopic.php?t=963671

                  I've checked ConnectionPool Mbean and found there is no connection leak. Only one connection were used for this task.