Tomcat jdbc-pool interceptor exception

Description

After update hibernate from 4.1.8.Final to 4.3.0.Final tomcat jdbc-pool start throwing this exceptions.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ... Caused by: java.lang.reflect.UndeclaredThrowableException: null at com.sun.proxy.$Proxy72.hashCode(Unknown Source) ~[na:na] at java.util.HashMap.hash(HashMap.java:351) ~[na:1.7.0_25] at java.util.HashMap.getEntry(HashMap.java:443) ~[na:1.7.0_25] at java.util.HashMap.get(HashMap.java:405) ~[na:1.7.0_25] at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.release(JdbcCoordinatorImpl.java:399) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.releaseStatements(AbstractBatchImpl.java:173) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:76) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3124) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3587) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:103) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:453) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:345) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1218) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:421) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177) ~[hibernate-core-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:77) ~[hibernate-entitymanager-4.3.0.Final.jar:4.3.0.Final] ... 90 common frames omitted Caused by: java.sql.SQLException: Statement closed. at org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementProxy.invoke(AbstractQueryReport.java:225) ~[tomcat-jdbc.jar:na] ... 109 common frames omitted

Next block contains AbstractQueryReport code, lines between 215 and 226

1 2 3 4 5 6 7 8 9 10 11 12 @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { //get the name of the method for comparison final String name = method.getName(); //was close invoked? boolean close = compare(JdbcInterceptor.CLOSE_VAL,name); //allow close to be called multiple times if (close && closed) return null; //are we calling isClosed? if (compare(JdbcInterceptor.ISCLOSED_VAL,name)) return Boolean.valueOf(closed); //if we are calling anything else, bail out if (closed) throw new SQLException("Statement closed.");

So looks like the code at 9ce5c32dd7d11bc13c659f98ee4cc29b26c2e70e it's not jdbc-pool friendly. Specifically the line JdbcCoordinatorImpl.java:399

1 final Set<ResultSet> resultSets = xref.get( statement );

To reproduce the exceptions just add some interceptor. For example add the next line to your server.xml resource configuration.

1 jdbcInterceptors="ConnectionState;StatementFinalizer;ResetAbandonedTimer;"

The exception in this description was thrown by the ResetAbandonedTimer interceptor.

Environment

Hibernate 4.3.0.Final, Mysql 5.5, Tomcat 7

Status

Assignee

Steve Ebersole

Reporter

Ignacio Baca Moreno-Torres

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.3.0.Final

Priority

Major
Configure