java.lang.Exception: Apparent connection leak detected I already checked and made sure all my sql codes has a call to close method. Here's my HikariConfig : private HikariConfig hikariConfig() { HikariConfig config = new HikariConfig(); config.setDriverClassName(CLASS_FOR_NAME); config.setJdbcUrl(HOST); config.setUsername(USER); config.setPassword(PASS); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(30)); config.setValidationTimeout(TimeUnit.MINUTES.toMillis(1)); config.setMaximumPoolSize(40); config.setMinimumIdle(0); config.setMaxLifetime(TimeUnit.MINUTES.toMillis(2)); // 120 seconds max life time config.setIdleTimeout(TimeUnit.MINUTES.toMillis(1)); // minutes config.setConnectionTimeout(TimeUnit.MINUTES.toMillis(5)); // millis config.setConnectionTestQuery("/* ping */ SELECT 1"); return config; } here's how my queries look like : public ArrayList<LocationType> getLocationTypes() { ArrayList<LocationType> locationTypes = new ArrayList<>(); Connection connection = null; PreparedStatement pstmt = null; ResultSet resultSet = null; try { connection = DataSource.getInstance().getConnection(); pstmt = connection.prepareStatement("SELECT\n" + " location_type_id,\n" + " location_type_name\n" + "FROM tablename;"); resultSet = pstmt.executeQuery(); while (resultSet.next()) { locationTypes.add(new LocationType(resultSet.getInt("location_type_id"), resultSet.getString("location_type_name"))); } } catch (Exception e) { e.printStackTrace(); } finally { if (resultSet != null) try { resultSet.close(); } catch (SQLException e) { } if (pstmt != null) try { pstmt.close(); } catch (SQLException e) { } if (connection != null) try { connection.close(); } catch (SQLException e) { } } return locationTypes; } I've already tried increasing the connectionLeakDetection, max connection and minimum idle but none of that solved the issue. I have read that it could be caused by the machine(low resources) and connections being closed, I think however, none of these causes the issue. I noticed that some long queries in my code are now being detected as connection leak, even though I am not calling their methods. I hope you guys could help. This is the stack trace : at com..database.DataSource.getConnection(DataSource.java:148)

Stack Overflow | JRojo | 7 months ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    HikariCP detects connectionleak even though all of my code has a call to close method

    Stack Overflow | 7 months ago | JRojo
    java.lang.Exception: Apparent connection leak detected I already checked and made sure all my sql codes has a call to close method. Here's my HikariConfig : private HikariConfig hikariConfig() { HikariConfig config = new HikariConfig(); config.setDriverClassName(CLASS_FOR_NAME); config.setJdbcUrl(HOST); config.setUsername(USER); config.setPassword(PASS); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(30)); config.setValidationTimeout(TimeUnit.MINUTES.toMillis(1)); config.setMaximumPoolSize(40); config.setMinimumIdle(0); config.setMaxLifetime(TimeUnit.MINUTES.toMillis(2)); // 120 seconds max life time config.setIdleTimeout(TimeUnit.MINUTES.toMillis(1)); // minutes config.setConnectionTimeout(TimeUnit.MINUTES.toMillis(5)); // millis config.setConnectionTestQuery("/* ping */ SELECT 1"); return config; } here's how my queries look like : public ArrayList<LocationType> getLocationTypes() { ArrayList<LocationType> locationTypes = new ArrayList<>(); Connection connection = null; PreparedStatement pstmt = null; ResultSet resultSet = null; try { connection = DataSource.getInstance().getConnection(); pstmt = connection.prepareStatement("SELECT\n" + " location_type_id,\n" + " location_type_name\n" + "FROM tablename;"); resultSet = pstmt.executeQuery(); while (resultSet.next()) { locationTypes.add(new LocationType(resultSet.getInt("location_type_id"), resultSet.getString("location_type_name"))); } } catch (Exception e) { e.printStackTrace(); } finally { if (resultSet != null) try { resultSet.close(); } catch (SQLException e) { } if (pstmt != null) try { pstmt.close(); } catch (SQLException e) { } if (connection != null) try { connection.close(); } catch (SQLException e) { } } return locationTypes; } I've already tried increasing the connectionLeakDetection, max connection and minimum idle but none of that solved the issue. I have read that it could be caused by the machine(low resources) and connections being closed, I think however, none of these causes the issue. I noticed that some long queries in my code are now being detected as connection leak, even though I am not calling their methods. I hope you guys could help. This is the stack trace : at com..database.DataSource.getConnection(DataSource.java:148)
  2. 0

    Console in Linux not working!

    Google Groups | 2 decades ago | bis...@my-deja.com
    java.lang.Exception: Certificate expired or not yet valid: fingerprint = 5ebfaa56b172893f050b19ae79d80547, not before = Fri Apr 28 15:03:47 PDT 2000, not after = Sun May 28 15:03:47 PDT 2000, holder = C=US SP=California L=San Francisco O=BEA WebLogic CN=weblogic.beasys.com Email=sup...@weblogic.com , issuer = C=US SP=California L=San Francisco O=WebLogic OU=Security CN=Demo Certificate Authority Email=secu...@weblogic.com , key = modulus length=65 exponent length=3 at weblogic.t3.srvr.SSLListenThread.insertIntoCAChain(SSLListenThread.java,Compiled Code) at weblogic.t3.srvr.SSLListenThread.<init>(SSLListenThread.java,Compiled Code) at weblogic.t3.srvr.SSLListenThread.<init>(SSLListenThread.java,Compiled Code) at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java, Compiled Code) at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java, Compiled Code)
  3. 0

    Forum Transport endpoint is not connected | Archivio del forum HTML.it

    html.it | 1 year ago
    java.lang.Exception: com.ibm.wsspi.webcontainer.ClosedConnectionExcepti on: OutputStream encountered error during write at it.usi.xframe.uwm.pfstruts.actions.ek.steps.Disbur sementAction.doPrintErgoInsurance(DisbursementActi on.java:1251) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:48) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    c3p0:JDBC DataSources/Resource Pools / Mailing Lists

    sourceforge.net | 1 year ago
    java.lang.Exception: DEBUG ONLY: Overdue resource check-out stack trace. >> at >> com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:506) >> at >> com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525) >> at >> com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) >> at >> org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.getTargetConnection(LazyConnectionDataSourceProxy.java:389) >> at >> org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:364) >> at $Proxy10.createStatement(Unknown Source) >> at >> org.sakaiproject.genericdao.util.CloseHookConnectionWrapper.createStatement(CloseHookConnectionWrapper.java:77) >> at >> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:390) >> at >> org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:429) >> at >> org.sakaiproject.genericdao.springjdbc.JdbcGenericDao.executeDDLforType(JdbcGenericDao.java:934) >> at >> org.sakaiproject.genericdao.springjdbc.JdbcGenericDao.initPersistentClasses(JdbcGenericDao.java:479) >> at >> org.sakaiproject.genericdao.springjdbc.JdbcGenericDao.initDao(JdbcGenericDao.java:568) >> at >> org.sakaiproject.genericdao.springjdbc.JdbcGenericDao.startup(JdbcGenericDao.java:504) >> at >> org.dspace.services.mapping.DatabaseIdEidMapping.<init>(DatabaseIdEidMapping.java:77) >> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native >> Method) >> at >> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) >> at >> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) >> at java.lang.reflect.Constructor.newInstance(Constructor.java:494) >> at >> org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100) >> at >> org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) >> at >> org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:248) >> at >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925) >> at >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835) >> at >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) >> at >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) >> at java.security.AccessController.doPrivileged(Native Method) >> at >> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) >> at >> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) >> at >> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) >> at >> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) >> at >> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) >> at >> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) >> at >> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) >> at >> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) >> at >> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) >> at >> org.dspace.servicemanager.spring.SpringServiceManager.startup(SpringServiceManager.java:195) >> at >> org.dspace.servicemanager.DSpaceServiceManager.startup(DSpaceServiceManager.java:222) >> at >> org.dspace.servicemanager.DSpaceKernelImpl.start(DSpaceKernelImpl.java:147) >> at >> org.dspace.DSpaceAbstractTest.initKernel(DSpaceAbstractTest.java:51) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  6. 0

    Re: JBoss have to close connection in managed environment and nes ted EJB calls

    apache.org | 2 years ago
    java.lang.Exception: STACKTRACE at >> >> > org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnect > ion(CachedConnectionManager.java:285) at >> >> > org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnecti > on(BaseConnectionManager2.java:525) at >> >> > org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManage > rProxy.allocateConnection(BaseConnectionManager2.java:887) at >> >> > org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataS > ource.java:102) at >> >> > org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.newConnectio > nFromDataSource(ConnectionFactoryAbstractImpl.java:204) at >> >> > org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.lookupConnec > tion(ConnectionFactoryAbstractImpl.java:112) at >> >> > org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl.lookupConnect > ion(ConnectionFactoryManagedImpl.java:33) at >> >> > org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.getConnection(Connec > tionManagerImpl.java:105) at >> >> > org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.localBegin(Connectio > nManagerImpl.java:147) at >> >> > org.apache.ojb.broker.core.PersistenceBrokerImpl.beginTransaction(Persistenc > eBrokerImpl.java:394) at >> >> > org.apache.ojb.broker.core.DelegatingPersistenceBroker.beginTransaction(Dele > gatingPersistenceBroker.java:138) at >> >> > org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl$PersistenceBroke > rSyncImpl.internBegin(PersistenceBrokerFactorySyncImpl.java:280) at >> >> > org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl$PersistenceBroke > rSyncImpl.access$000(PersistenceBrokerFactorySyncImpl.java:225) at >> >> > org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl.wrapRequestedBro > kerInstance(PersistenceBrokerFactorySyncImpl.java:153) at >> >> > org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl.createPersist > enceBroker(PersistenceBrokerFactoryDefaultImpl.java:105) at >> >> > org.apache.ojb.broker.core.PersistenceBrokerFactorySyncImpl.createPersistenc > eBroker(PersistenceBrokerFactorySyncImpl.java:116) at >> >> > org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.defaultPersisten > ceBroker(PersistenceBrokerFactoryBaseImpl.java:158) at >> >> > com.alabus.aes.server.ejb.application.system.AesUserBean.test1(AesUserBean.j > ava:205)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.Exception

      Apparent connection leak detected I already checked and made sure all my sql codes has a call to close method. Here's my HikariConfig : private HikariConfig hikariConfig() { HikariConfig config = new HikariConfig(); config.setDriverClassName(CLASS_FOR_NAME); config.setJdbcUrl(HOST); config.setUsername(USER); config.setPassword(PASS); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(30)); config.setValidationTimeout(TimeUnit.MINUTES.toMillis(1)); config.setMaximumPoolSize(40); config.setMinimumIdle(0); config.setMaxLifetime(TimeUnit.MINUTES.toMillis(2)); // 120 seconds max life time config.setIdleTimeout(TimeUnit.MINUTES.toMillis(1)); // minutes config.setConnectionTimeout(TimeUnit.MINUTES.toMillis(5)); // millis config.setConnectionTestQuery("/* ping */ SELECT 1"); return config; } here's how my queries look like : public ArrayList<LocationType> getLocationTypes() { ArrayList<LocationType> locationTypes = new ArrayList<>(); Connection connection = null; PreparedStatement pstmt = null; ResultSet resultSet = null; try { connection = DataSource.getInstance().getConnection(); pstmt = connection.prepareStatement("SELECT\n" + " location_type_id,\n" + " location_type_name\n" + "FROM tablename;"); resultSet = pstmt.executeQuery(); while (resultSet.next()) { locationTypes.add(new LocationType(resultSet.getInt("location_type_id"), resultSet.getString("location_type_name"))); } } catch (Exception e) { e.printStackTrace(); } finally { if (resultSet != null) try { resultSet.close(); } catch (SQLException e) { } if (pstmt != null) try { pstmt.close(); } catch (SQLException e) { } if (connection != null) try { connection.close(); } catch (SQLException e) { } } return locationTypes; } I've already tried increasing the connectionLeakDetection, max connection and minimum idle but none of that solved the issue. I have read that it could be caused by the machine(low resources) and connections being closed, I think however, none of these causes the issue. I noticed that some long queries in my code are now being detected as connection leak, even though I am not calling their methods. I hope you guys could help. This is the stack trace : at com..database.DataSource.getConnection(DataSource.java:148)

      at com.database.databaseServices.MileageReportService.MileageService.getMonthlySummaryBySID()
    2. com.database.databaseServices
      MileageService.getMonthlySummaryBySID
      1. com.database.databaseServices.MileageReportService.MileageService.getMonthlySummaryBySID(MileageService.java:27)
      1 frame
    3. com.views.reports
      MileageReport.lambda$generateReport$61446b05$1
      1. com.views.reports.mileage.MileageReport.lambda$generateReport$61446b05$1(MileageReport.java:103)
      1 frame
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:498)
      4 frames