Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PooledConnection has already been closed exception with Hibernate 4.2 [SPR-10395] #15028

Closed
spring-projects-issues opened this issue Mar 18, 2013 · 3 comments
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 18, 2013

Andreas Joseph Krogh opened SPR-10395 and commented

When using Spring's JdbcTemplate inside a transactional-service with the JpaTransactionmanager and the HibernateJpaDialect an exception is thrown.

Using Hibernate-4.2.0.Final, JPA, Spring-3.2.2 and I get:

Caused by: java.sql.SQLException: PooledConnection has already been closed.
        at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:86)
        at com.sun.proxy.$Proxy19.commit(Unknown Source)
        at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:112)
        ... 44 more

This happens both with c3p0 and tomcat-pool that comes with tomcat7.

I've tested in two projects with the same results. This doesn't happen with Hibernate-4.1.x

I know i should provide a test-case but I only have a scala-project at hand and you probably want that out of the equation...


Affects: 3.2.2

Attachments:

Issue Links:

6 votes, 12 watchers

@spring-projects-issues
Copy link
Collaborator Author

Andreas Joseph Krogh commented

Attached example maven-project.
extract it and run "mvn install" and it fails.

Replacing the Hibernate-version with 4.1.9.Final works.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 29, 2013

Juergen Hoeller commented

The problem here is that Hibernate 4.2 exposes the actual underlying Connection now - instead of the "borrowed connection" handle that it used to return, which was a proxy that interpreted a "close()" call as returning the borrowed connection to the Hibernate Session.

I've fixed this in the course of other JPA-related changes for 4.0 M1, with HibernateJpaDialect's HibernateConnectionHandle simply not calling "close()" on a Hibernate 4.x provided Connection anymore. In contrast to Hibernate 3.6 (see #11560), Hibernate 4.1 didn't do anything special when receiving a "close()" call on a borrowed connection handle, so it should be safe to not call "close()" against Hibernate 4.x in general.

To be backported to 3.2.3. Note that we need to make sure that we're not sacrificing HibernateJpaDialect's JPA 1.0 and Hibernate 3.2-3.5 compatibility there. I would also suggest to keep 3.2.3 compiling and testing against Hibernate 4.1 since that is the primary version that it has been designed for. 4.0 M1 compiles against Hibernate 4.2 now and needs to be tested against 4.2 as well as the upcoming 4.3 (with JPA 2.1 support).

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Ramesh Samarasam commented

I'm having the same exception with the Hibernate 4.1.9.Final and spring framework 3.1.3.RELEASE, Please help
Tomcat Version is 7.0.37
Connection has already been closed. (java.sql.SQLException) org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:117) org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:109) org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:80) com.sun.proxy.$Proxy33.rollback(Unknown Source)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants