[jboss-user] [JCA/JBoss] - Re: IDLE Connections and Pool ConnectionDestroyedCount near

skajotde do-not-reply at jboss.com
Thu Aug 30 04:30:34 EDT 2007


Hello, I sorry for long code pasted.

"vickyk" wrote : 
  | Check the listInUseConnections() operation in the CachedConnectionManager Mbean from the jmx-console . This will tell you what connections are not getting closed from your application .
  | All you need is to identify the application part which is leaking the connection and fix it.

Thanks for your suggestion ;>

In my jmx (listInUseConnections() CachedConnectionManager) thera are that tracktrace:

  | {org.jboss.resource.adapter.jdbc.WrappedConnection at 7166482f=java.lang.Throwable: STACKTRACE
  | 
  | 	at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:333)
  | 
  | 	at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:482)
  | 
  | 	at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:894)
  | 
  | 	at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:73)
  | 
  | 	at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
  | 
  | 	at org.hibernate.jdbc.JDBCContext.userConnection(JDBCContext.java:114)
  | 
  | 	at org.hibernate.impl.SessionImpl.connection(SessionImpl.java:366)
  | 
  | 	at pl.edu.uwm.student.dao.bazowe.BazowyJdbcDAO.utworzCallableStatement(BazowyJdbcDAO.java:40)
  | 
  | 	at pl.edu.uwm.student.admi.konfiguracja.dao.NumerAlbumuDAO.pobierzKolejnyNumer(NumerAlbumuDAO.java:45)
  | 
  | 	at pl.edu.uwm.student.admi.konfiguracja.ejb.FasadaNumerAlbumuDAOBean.pobierzKolejnyNumer(FasadaNumerAlbumuDAOBean.java:35)
  | 
  | 	at sun.reflect.GeneratedMethodAccessor450.invoke(Unknown Source)
  | 
  | 	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.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)
  | 
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
  | 
  | 	at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:27)
  | 
  | 	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.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
  | 
  | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
  | 
  | 	at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:151)
  | 
  | 	at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:85)
  | 
  | 	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.stateless.StatelessContainer.localInvoke(StatelessContainer.java:163)
  | 
  | 	at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:60)
  | 
  | 	at $Proxy168.pobierzKolejnyNumer(Unknown Source)
  | 
  | 	at pl.edu.uwm.student.web.kart.studenci.rejestracja.akcje.RejestracjaStudentaAction.handlerGenerujNrAlbumu(RejestracjaStudentaAction.java:292)
  | 
  | 	at sun.reflect.GeneratedMethodAccessor433.invoke(Unknown Source)
  | 
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 
  | 	at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
  | 
  | 	at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
  | 
  | 	at pl.edu.uwm.student.web.bazowe.akcje.BazowyAction.execute(BazowyAction.java:41)
  | 
  | 	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
  | 
  | 	at pl.edu.uwm.student.web.bazowe.SystemowyRequestProcessor.processActionPerform(SystemowyRequestProcessor.java:149)
  | 
  | 	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
  | 
  | 	at pl.edu.uwm.student.web.bazowe.SystemowyRequestProcessor.process(SystemowyRequestProcessor.java:92)
  | 
  | 	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
  | 
  | 	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
  | 
  | 	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 pl.edu.uwm.student.web.bazowe.SystemowyFilter.doFilter(SystemowyFilter.java:48)
  | 
  | 	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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
  | 
  | 	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)
  | 
  | ,
  | 

Hm, I have checked Code which looks like:
=====================================


  | public class NumerAlbumuDAO   {
  |     
  |     // ...
  | 
  |     public NumerAlbumuDAO(EntityManager arg0) {
  |         super(arg0);
  |     }
  | 
  |     private static final String SQL_KOLEJNY = "{ ? = call nextval('admi.sq_numer_albumu') }";
  | 
  |     /**
  |      * ...
  |      */
  |     public Integer pobierzKolejnyNumer() {
  |         CallableStatement stmt = utworzCallableStatement(SQL_KOLEJNY);
  |         Long numer = pobierzLong(stmt, SQL_KOLEJNY); 
  |         return numer.intValue();
  |     }
  | 
  |     protected CallableStatement utworzCallableStatement(String pSql) {
  |         CallableStatement stmt = null;
  |         try {
  |             stmt = pobierzSesje(em).connection().prepareCall(pSql);
  |             if (log.isDebugEnabled()) log.debug("[NOWY CALLABLE STATEMENT] " + pSql);
  |         } catch (Exception e) {
  |             log.fatal("B??d tworzenia statement",e);
  |             throw new EWyjatekInfrastruktury(e);
  |         }
  |         return stmt;
  |     }
  |     
  |     public Session pobierzSesje(EntityManager em) {
  |         if (em instanceof HibernateSession) {
  |             return ((HibernateSession)em).getHibernateSession();    
  |         } else {
  |             return ((EntityManagerImpl)em).getSession();
  |         }        
  |     }
  | 
  |     protected Long pobierzLong(CallableStatement stmt, String info) {
  |         try {
  |             stmt.registerOutParameter(1, Types.BIGINT);
  |             stmt.execute();         
  |             return (Long) stmt.getLong(1);
  |         } catch (SQLException e) {
  |             throw new EWyjatekInfrastruktury(e);            
  |         } finally {
  |             zamknijStatement(stmt);         
  |         }
  |     }
  | 
  |     protected void zamknijStatement(PreparedStatement pStmt) {
  |         if (pStmt != null) {
  |             try {
  |                 pStmt.close();
  |             } catch (Exception ee) {
  |             }
  |         }
  |     }    
  | 
  | }
  | 

Hm, I use hibernate as entitymanager and ejb3. In rare case like this I use raw SQL statements. 

Errors appears on high load on production server. As results all connections from pool (400) are in use and this ends with exception "No ManagedConnections available within configured blocking timeout"

Are you think this code is right ? I will very appreciate for suggestions

--
Kamil

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079474#4079474

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079474



More information about the jboss-user mailing list