Hi,
I have recently migrated from Hibernate 2.1.8 to 3.1.2.
I have managed to:
1) Replace all JARs with newer versions from 3.1.2
2) Search and replace the DTD URLs in all *.hbm.xml files
3) Search and replace net.sf.hibernate to org.hibernate
4) Update *.hbm.xml with correct lazy attributes that replicates the previous behaviour that we were expecting with HIbernate 2.1.8
5) Created hibernet.cfg-test.xml and hibernate.cfg-prod.xml ( based on hibernate.properties )
6) Updated code to load Hibernate configuration from either hibernate.cfg-test.xml or hibernate.cfg-prod.xml ( instead of hibernate.test.properties or hibernate.prod.properties ) based on a system environment variable.
7) Disable c3p0 connection pooling for the moment.
Everything works fine without c3p0. From the log files, when I dont use c3p0, it was using a built-in hibernate connection pooling which works fine as well.
However, as soon as I turn on c3p0 ( by putting in the properties in hibernate.cfg.xml ), the JDBC connection is closed just as immediately after obtaining metadata. That is what I can see from an ethereal trace, the JDBC connetion was sending a "TDS logout", and thus, the stack trace below which says "...has been closed() -- you can no longer use it."
What is interesting was c3p0 was working fine when we were using Hibernate 2.1.8
Hibernate version: 3.1.2
c3p0.properties:
Code:
c3p0.testConnectionOnCheckout=true
c3p0.testConnectionsOnCheckout=true
c3p0.initialPoolSize=3
c3p0.preferredTestQuery=select 1
c3p0.maxIdleTime=300
c3p0.minPoolSize=2
c3p0.maxPoolSize=20
c3p0.maxStatements=50
c3p0.acquireIncrement=2
c3p0.idleConnectionTestPeriod=300
hibernate.cfg.xml:This is really hibernate.cfg-test.xml:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.sybase.jdbc2.jdbc.SybDriver</property>
<property name="hibernate.connection.url">jdbc:sybase:Tds:192.168.0.80:4100?BE_AS_JDBC_COMPLIANT_AS_POSSIBLE=true&DYNAMIC_PREPARE=true&SELECT_OPENS_CURSOR=false&PACKETSIZE=4096</property>
<property name="hibernate.connection.username">sgtest</property>
<property name="hibernate.connection.password">sgtest</property>
<property name="hibernate.connection.pool_size">20</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.SybaseDialect</property>
<property name="hibernate.use_outer_join">false</property>
<property name="hibernate.max_fetch_depth">0</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.acquire_increment">2</property>
<property name="c3p0.idle_test_period">60</property>
<property name="c3p0.min_size">2</property>
<property name="c3p0.max_size">10</property>
<property name="c3p0.max_statements">50</property>
<property name="c3p0.timeout">60</property>
<!-- property name="c3p0.validate">true</property-->
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.timeout">60</property>
<!-- property name="hibernate.c3p0.validate">true</property-->
<!-- Mapping files
<mapping resource="contact.hbm.xml"/>
-->
</session-factory>
</hibernate-configuration>
Full stack trace of any exception that occurs:Code:
2006-03-08 13:25:51 LoginServlet: Validating user jsalvo
2006-03-08 13:26:00 LoginServlet: Error during login
org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:363)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:122)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
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.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1129)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.mig.provisioning.db.hibernate.ProvisioningUserDAO.validateLogin(ProvisioningUserDAO.java:17)
at com.mig.provisioning.LoginServlet.processRequest(LoginServlet.java:37)
at com.mig.provisioning.LoginServlet.doPost(LoginServlet.java:23)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:445)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@129e5e9 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1c6e818 [ acquireIncrement -> 2, autoCommitOnClose -> false, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 300, initialPoolSize -> 2, maxIdleTime -> 60, maxPoolSize -> 10, maxStatements -> 50, minPoolSize -> 2, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1b5391b [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:sybase:Tds:192.168.0.80:4100?BE_AS_JDBC_COMPLIANT_AS_POSSIBLE=true&DYNAMIC_PREPARE=true&SELECT_OPENS_CURSOR=false&PACKETSIZE=4096, properties -> {user=sgtest, password=sgtest} ] , propertyCycle -> 300, testConnectionOnCheckout -> true ] , 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 org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:360)
... 49 more
Name and version of the database you are using:Adaptive Server Enterprise, version: Adaptive Server Enterprise/12.5.3/EBF 12868 ESD#4/P/Sun_svr4/OS 5.8/ase1253/1923/32-bit/FBO/Thu Sep 8 14:14:28 2005
Using JConnect JDBC driver ( as shown from hibernate.cfg.xml file )
Other log files:< .... snip .... >
Code:
2006-03-08 13:25:58,735 [http-8080-Processor4] INFO - table found: sgtest.dbo.provisioning_state
2006-03-08 13:25:58,735 [http-8080-Processor4] INFO - table found: sgtest.dbo.provisioning_state
2006-03-08 13:25:58,735 [http-8080-Processor4] INFO - columns: [provisioning_state_id, description]
2006-03-08 13:25:58,735 [http-8080-Processor4] INFO - columns: [provisioning_state_id, description]
2006-03-08 13:25:58,735 [http-8080-Processor4] INFO - foreign keys: []
2006-03-08 13:25:58,735 [http-8080-Processor4] INFO - foreign keys: []
2006-03-08 13:25:58,735 [http-8080-Processor4] INFO - indexes: [provisioning_state_pk]
2006-03-08 13:25:58,735 [http-8080-Processor4] INFO - indexes: [provisioning_state_pk]
2006-03-08 13:25:59,108 [http-8080-Processor4] INFO - table found: sgtest.dbo.provisioning_state_association
2006-03-08 13:25:59,108 [http-8080-Processor4] INFO - table found: sgtest.dbo.provisioning_state_association
2006-03-08 13:25:59,108 [http-8080-Processor4] INFO - columns: [provisioning_state_id, parent_id]
2006-03-08 13:25:59,108 [http-8080-Processor4] INFO - columns: [provisioning_state_id, parent_id]
2006-03-08 13:25:59,108 [http-8080-Processor4] INFO - foreign keys: [provisioning_state_assocfk1, fk2af7690159a1ebd9, fk2af76901bfa4aba4, provisioning_state_assocfk2]
2006-03-08 13:25:59,108 [http-8080-Processor4] INFO - foreign keys: [provisioning_state_assocfk1, fk2af7690159a1ebd9, fk2af76901bfa4aba4, provisioning_state_assocfk2]
2006-03-08 13:25:59,108 [http-8080-Processor4] INFO - indexes: [provisioning_state_assoc_idx2, provisioning_state_assoc_idx1]
2006-03-08 13:25:59,108 [http-8080-Processor4] INFO - indexes: [provisioning_state_assoc_idx2, provisioning_state_assoc_idx1]
2006-03-08 13:25:59,451 [http-8080-Processor4] INFO - table found: sgtest.dbo.provisioning_user
2006-03-08 13:25:59,451 [http-8080-Processor4] INFO - table found: sgtest.dbo.provisioning_user
2006-03-08 13:25:59,451 [http-8080-Processor4] INFO - columns: [user_name, user_password, provisioning_user_id]
2006-03-08 13:25:59,451 [http-8080-Processor4] INFO - columns: [user_name, user_password, provisioning_user_id]
2006-03-08 13:25:59,451 [http-8080-Processor4] INFO - foreign keys: []
2006-03-08 13:25:59,451 [http-8080-Processor4] INFO - foreign keys: []
2006-03-08 13:25:59,451 [http-8080-Processor4] INFO - indexes: [provisioning_user_pk, provisioning_user_udx]
2006-03-08 13:25:59,451 [http-8080-Processor4] INFO - indexes: [provisioning_user_pk, provisioning_user_udx]
2006-03-08 13:25:59,452 [http-8080-Processor4] INFO - schema update complete
2006-03-08 13:25:59,452 [http-8080-Processor4] INFO - schema update complete
2006-03-08 13:26:00,118 [http-8080-Processor4] WARN - SQL Error: 0, SQLState: null
2006-03-08 13:26:00,118 [http-8080-Processor4] ERROR - com.mchange.v2.c3p0.PoolBackedDataSource@129e5e9 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1c6e818 [ acquireIncrement -> 2, autoCommitOnClose -> false, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 300, initialPoolSize -> 2, maxIdleTime -> 60, maxPoolSize -> 10, maxStatements -> 50, minPoolSize -> 2, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1b5391b [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:sybase:Tds:192.168.0.80:4100?BE_AS_JDBC_COMPLIANT_AS_POSSIBLE=true&DYNAMIC_PREPARE=true&SELECT_OPENS_CURSOR=false&PACKETSIZE=4096, properties -> {user=sgtest, password=sgtest} ] , propertyCycle -> 300, testConnectionOnCheckout -> true ] , factoryClassLocation -> null, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.