-->
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.  [ 2 posts ] 
Author Message
 Post subject: hibernate + primrose pool connection closed after some time
PostPosted: Mon Oct 19, 2009 2:08 pm 
Newbie

Joined: Fri Apr 03, 2009 4:12 pm
Posts: 9
I have an application running under a tomcat with a primrose pool. The application uses the datasource for connecting to an oracle database.

The problem is that after several hours of deploying/restrting the app I start getting "closed connection" exceptions:

Code:
org.hibernate.exception.GenericJDBCException: could not execute query
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.loader.Loader.doList(Loader.java:2223)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
        at org.hibernate.loader.Loader.list(Loader.java:2099)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
        at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
        at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
    .....
    .....
Caused by: java.sql.SQLException: Closed Connection
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:219)
        at oracle.jdbc.driver.OracleConnection.prepareStatement(OracleConnection.java:337)
        at uk.org.primrose.pool.core.PoolConnection.prepareStatement(PoolConnection.java:186)
        at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
        at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
        at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
        at org.hibernate.loader.Loader.doQuery(Loader.java:673)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        at org.hibernate.loader.Loader.doList(Loader.java:2220)

 


I suppose this is because primrose is dropping the connection

Unfourtunately I cannot find any documentation about hibernate + primrose or how to make hibernate reconnect to the database. The only hint I got was to use
Code:
<property name="hibernate.autoReconnect">true</property>
But I also read that this was not recommended (Don´t know why)

this is the hibernate conf (V3.2 using annotations)
Code:

<hibernate-configuration>

<session-factory>
   <property name="hibernate.hbm2ddl.auto">update</property>
   <property name="connection.datasource">
      java:comp/env/l2bhiponac
   </property>
   <property name="dialect">
      org.hibernate.dialect.Oracle9Dialect
   </property>
   <property name="hibernate.show_sql">false</property>
   <property name="hibernate.cglib.use_reflection_optimizer">false</property>
   <property name="hibernate.cache.use_second_level_cache">false</property>
</session-factory>

</hibernate-configuration>


dthe pool config looks like this:

Code:

poolName=l2bhiponac
base=5
overflow=5
log=/var/log/pools-dev.l2bhiponac-${yyyy-MM-dd}.log
idleTime=60000
messageLogging=false
sizeLogging=true
driverClass=oracle.jdbc.driver.OracleDriver
driverURL=jdbc:oracle:thin:@XXX.XX.XX.XX:YY:secret
user=secret
password=verysecret
killActiveConnectionsOverAge=3000
cycleConnections=1000
queueConnectionRequests=true
runPooledMode=true



I would really like to keep the pool since is the same pool we use for the others applications (they doesnt use hibernate) and I have to put the app in many tomcats with the pool using different users.

Any idea of how can I resolve this?

Thank you in advance.

_________________
Santiago García Pimentel R.G.


Top
 Profile  
 
 Post subject: Re: hibernate + primrose pool connection closed after some time
PostPosted: Mon Oct 26, 2009 11:51 am 
Newbie

Joined: Fri Apr 03, 2009 4:12 pm
Posts: 9
Hello again,

The IT guys just give me some information about what is going on. Apparently the application is using all the available conections from the pool .We tried to allow more conections but it only make the problem appear after a longer time.

I don't know why the pool is being overused. All my transactions look like this:

Code:
CorredorDAO DAO=new CorredorDAO();
try {
DAO.getSession().beginTransaction();
DAO.findSomething();
DAO.saveThis();
....
...
DAO.getSession().getTransaction().commit();
} catch (HibernateException e) {
   e.printStackTrace();
}finally{
   DAO.getSession().flush();
   DAO.getSession().clear();
   DAO.getSession().close();
   DAO.getSession().disconnect();
}



Before I was only committing and flushing but In my desperation I added the close and disconnect calls with the hope of solving the problem.

The session if obtained from a call to sessionFactory.openSession()

Any ideas of how can I solve the problem?

_________________
Santiago García Pimentel R.G.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.