0 Replies Latest reply on Apr 24, 2018 2:00 AM by Markus Fried

    Wildfly12 - Hibernate not releasing connections to pool

    Markus Fried Newbie

      Hi,

       

      I've got a running app on Weblogic 12 using Hibernate. Now I need to make it compatible with Wildfly 12. We're using Hibernate as ORM here, config follows.

      Problem now is, that Wildfly's connection pool runs out of conns after a few requests, since obviously Hibernate does not return elements back to it.

      connection.release_mode is set correctly (I think) in hibernate.cfg.xml

        <property name="transaction.flush_before_completion">true</property>
         <property name="transaction.auto_close_session">true</property>
         <property name="connection.release_mode">after_statement</property>

      We're using container managed transactions in our EJBs, DB is Oracle.

      Datasource is configured like this:

         <datasource jta="true" jndi-name="java:/jdbc/psqlWSDS" pool-name="OracleDS" enabled="true" use-ccm="false">
              <connection-url>jdbc:oracle:thin:@//XXX.XXX.XXX.XXX:1521/XXX</connection-url>
              <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
              <driver>oracle</driver>
              <pool>
                   <min-pool-size>1</min-pool-size>
                   <initial-pool-size>1</initial-pool-size>
                   <max-pool-size>30</max-pool-size>
              </pool>
              <security>
                   <user-name>XXX</user-name>
                   <password>XXX</password>
              </security>
              <validation>
                   <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
                   <background-validation>true</background-validation>
                   <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
                   <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
              </validation>
         </datasource>

       

      Stracktrace looks like this:

      Caused by: javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:158)
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:255)
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:332)
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:238)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
      at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:72)
      at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:47)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:100)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.deployment.processors.StartupAwaitInterceptor.processInvocation(StartupAwaitInterceptor.java:22)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:67)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:438)
      at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:619)
      at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:57)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
      at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:198)
      at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:185)
      at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:81)
      at com.jquick.webservices.components.lock.ejb.LockManagerBusiness$$$view33.hasLock(Unknown Source)
      at com.jquick.webservices.session.DefaultService.hasLock(DefaultService.java:630)
      at com.jquick.webservices.components.um.service.UMService.getBenutzer(UMService.java:1532)
      at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.jquick.webservices.session.invoker.InvokerBean.doInvokeService(InvokerBean.java:245)
      ... 248 more
      Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:149)
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
      at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1423)
      at com.jquick.webservices.components.lock.dao.LockDAOHibernate.findByApplicationIdAndItemId(LockDAOHibernate.java:91)
      at com.jquick.webservices.components.lock.ejb.LockManagerEJB.hasLockFromMe(LockManagerEJB.java:247)
      at com.jquick.webservices.components.lock.ejb.LockManagerEJB.hasLock(LockManagerEJB.java:230)
      at sun.reflect.GeneratedMethodAccessor175.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
      at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:90)
      at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:101)
      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:40)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
      at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:52)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:253)
      ... 288 more
      Caused by: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
      at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:118)
      at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:145)
      at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:47)
      at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146)
      at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172)
      at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148)
      at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1995)
      at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1925)
      at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1903)
      at org.hibernate.loader.Loader.doQuery(Loader.java:948)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:351)
      at org.hibernate.loader.Loader.doList(Loader.java:2702)
      at org.hibernate.loader.Loader.doList(Loader.java:2685)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2517)
      at org.hibernate.loader.Loader.list(Loader.java:2512)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:384)
      at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
      at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1490)
      at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445)
      at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)
      ... 315 more
      Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/jdbc/psqlWSDS
      at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:146)
      at org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64)
      at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
      at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:35)
      at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:115)
      ... 335 more
      Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:/jdbc/psqlWSDS
      at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:690)
      at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:430)
      at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:789)
      at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:138)
      ... 339 more
      Caused by: javax.resource.ResourceException: IJ000655: No managed connections available within configured blocking timeout (30000 [ms])
      at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:570)
      at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getTransactionNewConnection(AbstractPool.java:714)
      at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:613)
      at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:624)
      ... 342 more

       

      I tried changing the release_mode to other settings with no effect, Hibernate does not release connections to the pool.

      Flushing the connections from Wildfly's datasource statistics page releseases the connections.

      So any hints, how to get the connection pool running as intended would be greatly appreciated ;-)

      Best regards

      Mark.