-->
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.  [ 5 posts ] 
Author Message
 Post subject: **** NOT releasing the DB connections - ERROR ****
PostPosted: Tue Feb 01, 2005 12:36 pm 
Newbie

Joined: Thu Jan 13, 2005 6:30 pm
Posts: 12
Hibernate version:
2.1

Code between sessionFactory.openSession() and session.close():

session =sessionFactory.openSession(new ValidationInterceptor ());

tx= session.beginTransaction();

for (int j = 0 ; j < shList.size() ; j++) {

StakeHolder sh = new StakeHolder ((String[]) shList.get(j)) ;
session.save(sh);
sh = null ;

}

tx.commit();

} catch (Exception e) {
e.printStackTrace();
if (tx!=null) tx.rollback();

} finally{
// System.out.println ("CLOSING...") ;
session.close();
System.out.println ("CLOSED...") ;
}


Full stack trace of any exception that occurs:


[1/27/05 12:27:49:454 MST] 60124905 Environment I net.sf.hibernate.cfg.Environment Hibernate 2.1.7
[1/27/05 12:27:49:454 MST] 60124905 Environment I net.sf.hibernate.cfg.Environment hibernate.properties not found
[1/27/05 12:27:49:470 MST] 60124905 Environment I net.sf.hibernate.cfg.Environment using CGLIB reflection optimizer
[1/27/05 12:27:49:470 MST] 60124905 Environment I net.sf.hibernate.cfg.Environment using JDK 1.4 java.sql.Timestamp handling
[1/27/05 12:27:49:485 MST] 60124905 Configuration I net.sf.hibernate.cfg.Configuration configuring from resource: /hibernate.cfg.xml
[1/27/05 12:27:49:485 MST] 60124905 Configuration I net.sf.hibernate.cfg.Configuration Configuration resource: /hibernate.cfg.xml
[1/27/05 12:27:50:220 MST] 60124905 Configuration I net.sf.hibernate.cfg.Configuration Mapping resource: StakeHolder.hbm.xml
[1/27/05 12:27:50:735 MST] 60124905 Binder I net.sf.hibernate.cfg.Binder Mapping class: ca.shell.pcsv2.StakeHolder -> PCS_STAKEHOLDER
[1/27/05 12:27:51:141 MST] 60124905 Configuration I net.sf.hibernate.cfg.Configuration Configured SessionFactory: null
[1/27/05 12:27:51:141 MST] 60124905 Configuration I net.sf.hibernate.cfg.Configuration processing one-to-many association mappings
[1/27/05 12:27:51:141 MST] 60124905 Configuration I net.sf.hibernate.cfg.Configuration processing one-to-one association property references
[1/27/05 12:27:51:141 MST] 60124905 Configuration I net.sf.hibernate.cfg.Configuration processing foreign key constraints
[1/27/05 12:27:51:345 MST] 60124905 Dialect I net.sf.hibernate.dialect.Dialect Using dialect: net.sf.hibernate.dialect.OracleDialect
[1/27/05 12:27:51:407 MST] 60124905 SettingsFacto I net.sf.hibernate.cfg.SettingsFactory Use outer join fetching: true
[1/27/05 12:27:51:438 MST] 60124905 DriverManager I net.sf.hibernate.connection.DriverManagerConnectionProvider Using Hibernate built-in connection pool (not for production use!)
[1/27/05 12:27:51:438 MST] 60124905 DriverManager I net.sf.hibernate.connection.DriverManagerConnectionProvider Hibernate connection pool size: 20
[1/27/05 12:27:51:438 MST] 60124905 DriverManager I net.sf.hibernate.connection.DriverManagerConnectionProvider using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@orasv1.shell.ca:1521:TST4
[1/27/05 12:27:51:438 MST] 60124905 DriverManager I net.sf.hibernate.connection.DriverManagerConnectionProvider connection properties: {user=PCDB, password=anwarm}
[1/27/05 12:27:51:485 MST] 60124905 TransactionMa I net.sf.hibernate.transaction.TransactionManagerLookupFactory No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
[1/27/05 12:27:51:532 MST] 60124905 SettingsFacto W net.sf.hibernate.cfg.SettingsFactory Could not obtain connection metadata
[1/27/05 12:27:51:579 MST] 60124905 SettingsFacto W net.sf.hibernate.cfg.SettingsFactory TRAS0014I: The following exception was logged java.sql.SQLException: ORA-00020: maximum number of processes (150) exceeded

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.O3log.receive1st(O3log.java:428)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:248)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:249)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:538)
at java.sql.DriverManager.getConnection(DriverManager.java:157)
at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:101)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1160)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:794)
at ca.shell.pcsv2.AddStakeHolder.saveStakeHolder(AddStakeHolder.java:44)
at ca.shell.pcsv2.ImportSHList.doImportButtonAction(ImportSHList.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:302)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:416)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:443)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))



Name and version of the database you are using:

Oracle 8i, Websphere Application Server



========================================

Problem is that i am reaching the "maximum processes" and as a result the application is failing.

Every time i instantiate and save() a persistent class, hibernate is opening a connection to the DB and keeping it open, even after a commit() or flush() or close(). Each time i run the application the new connections are opened, eventually leading to this error.

The only way i am able to get rid of these connections is by STOPping or RESTARTing the websphere application server. The oracle view SYS.V_$SESSION is testifying this fact.

PLEASE let me know how i can close/release the connections in code, when i am done with the work.

Thanks very much.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 02, 2005 3:09 pm 
Newbie

Joined: Thu Jan 13, 2005 6:30 pm
Posts: 12
I used connection pools to solve this problem.

Thanks...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 02, 2005 3:59 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
**** did you read the stacktrace ? ****

[1/27/05 12:27:51:438 MST] 60124905 DriverManager I net.sf.hibernate.connection.DriverManagerConnectionProvider Using Hibernate built-in connection pool (not for production use!)


you should also read the doc ;)

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 02, 2005 5:06 pm 
Newbie

Joined: Thu Jan 13, 2005 6:30 pm
Posts: 12
thanks anthony.

are you saying that the hibernate connection pools were the problem. they did not seem to be pooling the resources at all. every instance of my object was taking up a connection - and every time i run the app, they just keep growing.

to me that is not even connection pooling.

any comments?

i defined a datasource in the websphere app server and used that instead.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 02, 2005 6:16 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
when i say "you should read the doc", there must be a reason.

http://www.hibernate.org/hib_docs/refer ... ernatejdbc

Hibernate's own connection pooling algorithm is quite rudimentary. It is intended to help you get started and is not intended for use in a production system or even for performance testing. Use a third party pool for best performance and stability, i.e., replace the hibernate.connection.pool_size property with connection pool specific settings.



There are a lot of interesting things in the doc and i admit, it is generally necessary to read it at least twice.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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