hi folks, searched the forums and did not see this problem addressed. if it has a link would be appreciated.
i have a webapp instance, with multiple webapps being deployed and redeployed (it's a development environment). i have an application server-level (not web-app level) object ("manager") which has a reference to a singleton instance of a DAO object which is using hibernate. i was experiencing timeout problems with DBCP (well noted on these forums) and have switched to c3p0. each webapp is required to register/unregister with the manager (using a load-on-startup servlet's init/destroy methods). so,
Code:
public synchronized static void registerClient(String name){
if (instance == null){
//calls private init() method, initializing hibernate dao object
instance = new OfferCacheManager();
}
clientNum++;
}
public synchronized static void unregisterClient(String name){
clientNum--;
if (clientNum == 0){
//calls sessionFactory.shutdown();
shutdown();
}
}
initially (jvm startup), the manager instance is initialized in a static block. the register/unregister stuff happens fine, and as expected, when there are no webapps left shutdown gets called correctly. however, if i then redeploy without restarting the server, and try to get a new instance (which calls the Hibernate initialization code as follows:
Code:
{
net.sf.hibernate.cfg.Configuration config
= new net.sf.hibernate.cfg.Configuration();
Properties p = new Properties();
//go get properties
config.setProperties(props);
config.configure();
sessionFactory = config.buildSessionFactory();
}
) in registerClient(), i get the below error. note that this all works fine using DBCP, so i'm guessing i have to do something to accomodate c3p0...but i'm not sure what that might be. or is the answer to just always restart the server with a deploy (kind of a pain in development)? any ideas?
thanks in advance,
peter
Hibernate version:
hibernate 2.1,
c3p0 version 0.8.4.5
Mapping documents:
using resin, and programmatically creating a hibernate properties file to pass to configure with (jdbc connection params taken out):
<system-property hibernate.c3p0.acquire_increment="1"/>
<system-property hibernate.c3p0.idle_test_period="180"/>
<system-property hibernate.c3p0.max_size="100"/>
<system-property hibernate.c3p0.max_statements="0"/>
<system-property hibernate.c3p0.min_size="10"/>
<system-property hibernate.c3p0.timeout="100"/>
Full stack trace of any exception that occurs:
net.sf.hibernate.exception.GenericJDBCException: Cannot open connection
at net.sf.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:81)
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
at net.sf.hibernate.impl.BatcherImpl.convert(BatcherImpl.java:325)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:292)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3361)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3321)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:66)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:779)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.ch.qjOfferCache.DAO.hibernate.HibernateAppOfferDAO.doQuery(HibernateAppOfferDAO.java:461)
at com.ch.qjOfferCache.DAO.hibernate.HibernateAppOfferDAO.getAppDeptFromDeptClubCodes(HibernateAppOfferDAO.java:189)
at com.ch.qjOfferCache.offercache.OfferCacheManager.fetchJoinOffer(OfferCacheManager.java:459)
at com.ch.site.struts.actions.performers.ManageDBOfferCache.perform(ManageDBOfferCache.java:117)
at com.ch.site.struts.actions.LocaleAction.executePerformers(LocaleAction.java:134)
at com.ch.site.struts.actions.LocaleAction.perform(LocaleAction.java:92)
at org.apache.struts.action.Action.execute(Action.java:420)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at com.ch.site.struts.CustomActionServlet.process(CustomActionServlet.java:29)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.ch.site.filters.TrimLinesFilter.doFilter(TrimLinesFilter.java:48)
at com.caucho.server.http.FilterChainFilter.doFilter(FilterChainFilter.java:88)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@4adb34 [ connectionPoolDataSource -> com.mchange.v
2.c3p0.WrapperConnectionPoolDataSource@1ccbdf7 [ acquireIncrement -> 1, autoCommitOnClose -> false, connectionTesterClassName
-> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> fals
e, idleConnectionTestPeriod -> 180, initialPoolSize -> 10, maxIdleTime -> 100, maxPoolSize -> 100, maxStatements -> 0, minPoo
lSize -> 10, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@7d4275 [ description -> null, driverClass -> nul
l, factoryClassLocation -> null, jdbcUrl -> jdbc:informix-sqli://10.xxx.x.xx:9999/customer:INFORMIXSERVER=dbname, proper
ties -> {user=xxxxxx, password=xxxxxx} ] , propertyCycle -> 300, testConnectionOnCheckout -> false ] , factoryClassLocation -
> null, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.
at com.mchange.v2.c3p0.PoolBackedDataSource.assertCpds(PoolBackedDataSource.java:129)
at com.mchange.v2.c3p0.PoolBackedDataSource.getPoolManager(PoolBackedDataSource.java:141)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:58)
at net.sf.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:33)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:289)
... 34 more
Name and version of the database you are using:
informix