-->
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.  [ 13 posts ] 
Author Message
 Post subject: Problem with SchemaExport and C3P0
PostPosted: Thu Apr 07, 2005 5:29 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Hibernate version: 3.0 final
Database: MySQL 4.1.11
C3P0 version: 0.8.5.2

I have a problem with the schema export and C3P0.
Using the following code throws a SQLException (You can't operate on a closed connection!!!).
When uncommenting the line "schema.drop(true, true)" it works fine...


code
Code:
public static void main(String[] args) {
   final SchemaExport schemaExport = new SchemaExport(Li2DHibernateUtil.getConfiguration());
   schemaExport.setOutputFile(DDL_SCHEMA_OUTPUT);
   schemaExport.drop(true, true);
   schemaExport.create(true, true);
   System.exit(0);
}


exception
Code:
ERROR 07.04.2005 10:15:31,502 org.hibernate.tool.hbm2ddl.SchemaExport (SchemaExport:execute:180) - schema export unsuccessful
java.sql.SQLException: You can't operate on a closed connection!!!
   at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:68)
   at com.mchange.v2.c3p0.impl.NewProxyConnection.getAutoCommit(NewProxyConnection.java:815)
   at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:132)
   at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:100)
   at de.company.product.tools.DDLManager.main(DDLManager.java:39)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: java.lang.NullPointerException
   at com.mchange.v2.c3p0.impl.NewProxyConnection.getAutoCommit(NewProxyConnection.java:809)
   ... 8 more


hibernate.properties
Code:
hibernate.c3p0.max_size 150
hibernate.c3p0.min_size 3
hibernate.c3p0.timeout 0
hibernate.c3p0.max_statements 0
hibernate.c3p0.idle_test_period 0
hibernate.c3p0.acquire_increment 1


c3p0.properties
Code:
c3p0.initialPoolSize=3
c3p0.autoCommitOnClose=false
c3p0.forceIgnoreUnresolvedTransactions=false
com.mchange.v2.log.MLog=com.mchange.v2.log.log4j.Log4jMLog



Thanks for your help!

Best regards
Sven


Top
 Profile  
 
 Post subject: Re: Problem with SchemaExport and C3P0
PostPosted: Wed Apr 13, 2005 11:20 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
Seems, there's a bug in org.hibernate.tool.hbm2ddl.SchemaExport.
The connection handling has changed for 3.0 final(v1.4 in cvs).
I replaced it with the version from rc1(v1.3) and it works fine again.

regards,

h.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 11:26 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Thanks for your reply!
Should I record the issue in JIRA?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 12:11 pm 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
fine, then i don't have to do it... ;)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 12:23 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Just recorded this in JIRA. :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 14, 2005 4:01 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Well, Gavin assumes that this is a problem with c3p0.
http://opensource.atlassian.com/projects/hibernate/browse/HHH-341

I hope that a c3p0 developer will have a look at this. Steve? :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 12:21 pm 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
The latest c3p0 (0.9.0-pre5) fixes an issue that may be the source of this issue. I'd be glad you could verify this, or send me back to the drawing board...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 12:52 pm 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
I just tried c3p0 0.9.0-pre5 with Hibernate 3.0.2
Here's the log:

Code:
[hibernatetool] 18:46:25,671 [main] DEBUG GooGooStatementCache.checkinAll():196 - checkinAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 0; checked out: 0; num connections: 0; num keys: 0
[hibernatetool] 18:46:25,687 [main] DEBUG BasicResourcePool.trace():1117 - trace com.mchange.v2.resourcepool.BasicResourcePool@19646fd [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@126c6ea)
[hibernatetool] 18:46:25,687 [main] DEBUG GooGooStatementCache.closeAll():218 - ENTER METHOD: closeAll( net.sourceforge.jtds.jdbc.ConnectionJDBC3@1ca209e )! -- num_connections: 0
[hibernatetool] 18:46:25,687 [main] DEBUG GooGooStatementCache.closeAll():220 - Set of statements for connection: null
[hibernatetool] 18:46:25,687 [main] DEBUG GooGooStatementCache.closeAll():241 - closeAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 0; checked out: 0; num connections: 0; num keys: 0
[hibernatetool] 18:46:25,703 [main] DEBUG BasicResourcePool.trace():1117 - trace com.mchange.v2.resourcepool.BasicResourcePool@19646fd [managed: 0, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@126c6ea)
[hibernatetool] 18:46:25,703 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] DEBUG ThreadPoolAsynchronousRunner.run():397 - Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main] interrupted. Shutting down.
[hibernatetool] 18:46:25,703 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] DEBUG ThreadPoolAsynchronousRunner.run():397 - Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] interrupted. Shutting down.
[hibernatetool] 18:46:25,703 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] DEBUG ThreadPoolAsynchronousRunner.run():397 - Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main] interrupted. Shutting down.
[hibernatetool] 18:46:25,812 [main] DEBUG PoolBackedDataSource.close():214 - com.mchange.v2.c3p0.PoolBackedDataSource@d61aef has been closed. force_destroy == false
[hibernatetool] java.lang.Exception: Debug -- PoolBackedDataSource.close() stack trace.
[hibernatetool] at com.mchange.v2.c3p0.PoolBackedDataSource.close(PoolBackedDataSource.java:214)
[hibernatetool] at com.mchange.v2.c3p0.DataSources.destroy(DataSources.java:259)
[hibernatetool] at com.mchange.v2.c3p0.DataSources.destroy(DataSources.java:226)
[hibernatetool] at org.hibernate.connection.C3P0ConnectionProvider.close(C3P0ConnectionProvider.java:118)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.release(SchemaExport.java:382)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:187)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.drop(SchemaExport.java:109)
[hibernatetool] at org.hibernate.tool.ant.Hbm2DDLGeneratorTask.execute(Hbm2DDLGeneratorTask.java:39)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:101)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:414)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:139)
[hibernatetool] 18:46:25,859 [main] DEBUG SqlUtils.toSQLException():97 - Converting Throwable to SQLException...
[hibernatetool] java.lang.NullPointerException
[hibernatetool] at com.mchange.v2.c3p0.impl.NewProxyConnection.getAutoCommit(NewProxyConnection.java:810)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:132)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:100)
[hibernatetool] at org.hibernate.tool.ant.Hbm2DDLGeneratorTask.execute(Hbm2DDLGeneratorTask.java:40)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:101)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:414)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:139)
[hibernatetool] 18:46:25,890 [main] ERROR SchemaExport.execute():180 - schema export unsuccessful
[hibernatetool] java.sql.SQLException: You can't operate on a closed Connection!!!
[hibernatetool] at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:104)
[hibernatetool] at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65)
[hibernatetool] at com.mchange.v2.c3p0.impl.NewProxyConnection.getAutoCommit(NewProxyConnection.java:816)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:132)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:100)
[hibernatetool] at org.hibernate.tool.ant.Hbm2DDLGeneratorTask.execute(Hbm2DDLGeneratorTask.java:40)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:101)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:414)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:139)
[hibernatetool] Caused by: java.lang.NullPointerException
[hibernatetool] at com.mchange.v2.c3p0.impl.NewProxyConnection.getAutoCommit(NewProxyConnection.java:810)
[hibernatetool] ... 12 more
[hibernatetool] 18:46:25,921 [main] DEBUG SqlUtils.toSQLException():97 - Converting Throwable to SQLException...
[hibernatetool] java.lang.NullPointerException
[hibernatetool] at com.mchange.v2.c3p0.impl.NewProxyConnection.getWarnings(NewProxyConnection.java:732)
[hibernatetool] at org.hibernate.util.JDBCExceptionReporter.logAndClearWarnings(JDBCExceptionReporter.java:22)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.release(SchemaExport.java:380)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:187)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:100)
[hibernatetool] at org.hibernate.tool.ant.Hbm2DDLGeneratorTask.execute(Hbm2DDLGeneratorTask.java:40)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:101)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:414)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:139)
[hibernatetool] 18:46:26,500 [main] DEBUG NewProxyConnection.close():1155 - com.mchange.v2.c3p0.impl.NewProxyConnection@98bbf6: close() called more than once.
[hibernatetool] 18:46:26,500 [main] DEBUG PoolBackedDataSource.close():214 - com.mchange.v2.c3p0.PoolBackedDataSource@d61aef has been closed. force_destroy == false
[hibernatetool] java.lang.Exception: Debug -- PoolBackedDataSource.close() stack trace.
[hibernatetool] at com.mchange.v2.c3p0.PoolBackedDataSource.close(PoolBackedDataSource.java:214)
[hibernatetool] at com.mchange.v2.c3p0.DataSources.destroy(DataSources.java:259)
[hibernatetool] at com.mchange.v2.c3p0.DataSources.destroy(DataSources.java:226)
[hibernatetool] at org.hibernate.connection.C3P0ConnectionProvider.close(C3P0ConnectionProvider.java:118)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.release(SchemaExport.java:382)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:187)
[hibernatetool] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:100)
[hibernatetool] at org.hibernate.tool.ant.Hbm2DDLGeneratorTask.execute(Hbm2DDLGeneratorTask.java:40)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:101)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:414)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:139)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 9:29 am 
Regular
Regular

Joined: Tue Sep 28, 2004 5:18 pm
Posts: 55
Location: Switzerland
I'm also getting this Exception intermittently under c3p0 0.8.5.2. Haven't tried with 0.9 yet. Is this recommended?


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 01, 2005 5:24 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
h.b.,

thanks for the detailed log information. notice that something unusual is going on -- the DataSource is destroyed, but later use of a Connection obtained from that DataSource is attempted.

since the DataSource is destroyed with force_destroy set to false, c3p0 ought to support this case, however unusual it is. but it's not something i test a lot. i'll see if i can reproduce the issue, and get back to you soon.

smiles,
Steve (c3p0 guy)


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 01, 2005 5:26 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
tpischke,

i think your situation (judging from your post in another thread) is a bit different, and your problem is probably solved in c3p0-0.9.0-pre5. please do give it a shot.

smiles,
Steve (c3p0 guy)


Top
 Profile  
 
 Post subject: There's a bug in SchemaExport$ProviderConnectionHelper
PostPosted: Mon May 02, 2005 3:56 am 
Newbie

Joined: Mon May 02, 2005 3:47 am
Posts: 1
Location: Nashville, TN
There's a bug in the:

org.hibernate.tool.hbm2ddl.SchemaExport$ProviderConnectionHelper.release() method.

The connection member needs to be set to null here, otherwise next attempt to get a connection from this helper returns the closed connection. The bug is corrected with the following change:


public void release() throws SQLException {
if ( connection!=null ) {
JDBCExceptionReporter.logAndClearWarnings(connection);
connectionProvider.closeConnection( connection );
connectionProvider.close();
}
connection = null; // msoileau@airliftj.com: added to fix closed connection reuse bug

}

I'm not a committer so someone else will need to make the change.

thanks,
mark

_________________
Mark Soileau
Airlift Group, LLC
Airlift Framework Architect


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 02, 2005 6:06 am 
Regular
Regular

Joined: Tue Sep 28, 2004 5:18 pm
Posts: 55
Location: Switzerland
Hi Steve, thanks for the reply.

After seeing some other posts mentioning that a similar bug had been fixed in 0.9, I went ahead and upgraded our app to the latest c3p0 version. I'm happy to say that at least one reports that the problem no longer occurs. (I wasn't able to duplicate the problem personally).


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