-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Problem with datasource/connection pool in WebSphere 5.1
PostPosted: Fri Feb 02, 2007 10:42 am 
Newbie

Joined: Fri Feb 02, 2007 10:22 am
Posts: 5
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


    Top
     Profile  
     
     Post subject: Possible solution
    PostPosted: Tue Feb 06, 2007 4:02 am 
    Newbie

    Joined: Fri Feb 02, 2007 10:22 am
    Posts: 5
    I'm not yet 100% sure, but maybe I found a solution: setting the aged timeout on the connection pool of the datasource seems to fix the problem.


    Top
     Profile  
     
     Post subject: Stale Connection - SQL30081N
    PostPosted: Fri Jun 29, 2007 11:33 am 
    Newbie

    Joined: Fri Jun 29, 2007 11:25 am
    Posts: 1
    Location: Canada
    Hi,

    We have the same problem in our application. Intermittent Stale Connections occur. Did changing the aged timeout parameter work for you ?.. and what did you change it to ?

    Thanks
    Richard


    Top
     Profile  
     
     Post subject: DataSource Settings
    PostPosted: Mon Jul 02, 2007 2:48 am 
    Newbie

    Joined: Fri Feb 02, 2007 10:22 am
    Posts: 5
    Hi Richard,

    I think setting the aged timeout worked for me, although I suspect it's more like a workaround than a real solution. Anyhow, I set the the timeout for unused connection to 3600 seconds and the aged timeout to 10800 seconds. That value was arbitrarily choosen, I just thought that it probably should be rather long. Let me know if this works for you, too.
    Regards,

    Christian


    Top
     Profile  
     
    Display posts from previous:  Sort by  
    Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

    All times are UTC - 5 hours [ DST ]


    You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum

    Search for:
    © Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.