Hi all,
Setup is as follows:
Hibernate 3.1
WebSphere Application Server 5.1.1.11
Database IBM DB2 8.2
I'm having a problem with hibernate when using a datasource with a connection pool configured in IBM WebSphere Application Server 5.1.1.11. When using the datasource, I get a StaleConnectionException the first time I try to read (via Criteria.list) something from the database after a longer time (i.e. after the inactivity timeout of the pool has kicked in). The error only occurs on the first attempt to read, the following reads work fine. When I configure a JDBC URL in my hibernate.cfg.xml and a c3p0 connection pool, this problem does not occur, so it does not seem to be a problem with the implementation. For me, it really looks like ther is a problem with the connection pool configured in WebSphere. It looks very similar to the problems described in
http://forum.hibernate.org/viewtopic.php?t=929329 and
http://forum.hibernate.org/viewtopic.php?t=451 http://forum.hibernate.org/viewtopic.php?t=451, respectively. However, the described feature "auto connection cleanup" is only available for version 4 datasources (see
http://publib.boulder.ibm.com/infocente ... olset.html).
Has anyone successfully used a connection pool configured in WebSphere 5.1 with hibernate? How should the connection pool and hibernate be configured?
The properties in hibernate.cfg.cml look like this for the datasource:
Code:
...
<property name="hibernate.connection.datasource">jdbc/exampleDS</property>
<property name="hibernate.connection.release_mode">on_close</property>
<property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.max_fetch_depth">1</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.hbm2ddl.auto">none</property>
...
and like this when using th JDBC URL:
Code:
...
<property name="connection.driver_class">COM.ibm.db2.jdbc.net.DB2Driver</property>
<property name="connection.url">jdbc:db2://example.com:6789/exampleDB</property>
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<property name="connection.username">example</property>
<property name="connection.password">...</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.hbm2ddl.auto">none</property>
<property name="hibernate.show_sql">false</property>
<!-- configuration for c3p0 -->
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">90</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">50</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.timeout">900</property>
...
The seetings used for the datasource:
connection timeout: 180 seconds
minimum connection: 1
maximum connections: 50
reap time: 180 seconds
unused Timeout: 1800 seconds
aged timeout: 0
purge policy: entire pool
The exception that occurs when using the datasource is a com.ibm.websphere.ce.cm.StaleConnectionException (unfortunately, I only have acces to German log files, so I translated the localized messages, the following might thus differ slightly from the actual english messages):
Code:
ConnectionEve A J2CA0056I: The connection manager has received a fatal connection error from the resource adapter for resource jdbc/exampleDS. The exception was caused by com.ibm.websphere.ce.cm.StaleConnectionException: [IBM][CLI Driver] SQL30081N communication error. Communication protocol used: "TCP/IP". Commucation API used: "SOCKETS". Position where the error occured: "10.1.2.3". Function that detected the error: "send". Protocol specific error code(s): "10054", "*", "0". SQLSTATE=08001
WSRdbManagedC E DSRA0010E: SQL-Status = 08003, Error code = -99.999
WSRdbManagedC E DSRA0010E: SQL-Status = 08003, Error code = -99.999
WSRdbManagedC W DSRA0180W: An exception occured in ManagedConnection.destroy(). Exception is com.ibm.ws.exception.WsException: DSRA0080E: An exception was received by the Data Store Adapter. See original exception message: [IBM][CLI Driver] CLI0106E Connection is closed. SQLSTATE=08003. with SQL State : 08003 SQL Code : -99999
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Connection.rollback(Unknown Source)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions(WSRdbManagedConnectionImpl.java(Compiled Code))
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.destroy(WSRdbManagedConnectionImpl.java:2093)
at com.ibm.ejs.j2c.MCWrapper.destroy(MCWrapper.java:1397)
at com.ibm.ejs.j2c.poolmanager.FreePool.cleanupAndDestroyMCWrapper(FreePool.java:510)
at com.ibm.ejs.j2c.poolmanager.FreePool.returnToFreePool(FreePool.java(Compiled Code))
at com.ibm.ejs.j2c.poolmanager.PoolManager.release(PoolManager.java(Compiled Code))
at com.ibm.ejs.j2c.MCWrapper.releaseToPoolManager(MCWrapper.java(Compiled Code))
at com.ibm.ejs.j2c.MCWrapper.connectionErrorOccurred(MCWrapper.java:1875)
at com.ibm.ejs.j2c.ConnectionEventListener.connectionErrorOccurred(ConnectionEventListener.java:328)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processConnectionErrorOccurredEvent(WSRdbManagedConnectionImpl.java:1448)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.fireConnectionErrorEvent(WSJdbcConnection.java:1010)
at com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.mapException(WSJdbcUtil.java:899)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java(Compiled Code))
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java(Compiled Code))
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
...
Caused by: java.sql.SQLException: [IBM][CLI Driver] CLI0106E Connection is closed. SQLSTATE=08003DSRA0010E: SQL-Status = 08003, Error code = -99.999
... 34 more
---- Begin backtrace for nested exception
java.sql.SQLException: [IBM][CLI Driver] CLI0106E Connection is closed. SQLSTATE=08003DSRA0010E: SQL-Status = 08003, Error code = -99.999
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Connection.rollback(Unknown Source)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cleanupTransactions(WSRdbManagedConnectionImpl.java(Compiled Code))
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.destroy(WSRdbManagedConnectionImpl.java:2093)
at com.ibm.ejs.j2c.MCWrapper.destroy(MCWrapper.java:1397)
at com.ibm.ejs.j2c.poolmanager.FreePool.cleanupAndDestroyMCWrapper(FreePool.java:510)
at com.ibm.ejs.j2c.poolmanager.FreePool.returnToFreePool(FreePool.java(Compiled Code))
at com.ibm.ejs.j2c.poolmanager.PoolManager.release(PoolManager.java(Compiled Code))
at com.ibm.ejs.j2c.MCWrapper.releaseToPoolManager(MCWrapper.java(Compiled Code))
at com.ibm.ejs.j2c.MCWrapper.connectionErrorOccurred(MCWrapper.java:1875)
at com.ibm.ejs.j2c.ConnectionEventListener.connectionErrorOccurred(ConnectionEventListener.java:328)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processConnectionErrorOccurredEvent(WSRdbManagedConnectionImpl.java:1448)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.fireConnectionErrorEvent(WSJdbcConnection.java:1010)
at com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.mapException(WSJdbcUtil.java:899)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java(Compiled Code))
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java(Compiled Code))
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
...
I tried to describe this as concise as possible without adding (too many :-) pages of stack traces and configuration files. If you have an idea and need more information, please let me know, I'll be glad to post it here.
Thanks in advance,
Christian