1
votes

Where do you start when you have these problems? I'm having problems recreating these error in my development environment.

We are running this code on resin server. And we have plugins running in threads in a transaction.

And we have some code that flushes the session and some not. Is there some logging that provide some more useful information than this.

06:44:48 [ERROR]: AbstractHibernateFactory.java:127 - Cought this saving a sherlock.common.dao.BatchLog
org.hibernate.exception.JDBCConnectionException: could not insert: [sherlock.common.dao.BatchLog]
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2329)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2836)
    at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
    at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
    at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
    at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:677)
    at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:669)
    at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:665)
    at framework.hibernate.service.AbstractHibernateFactory.saveOrUpdate(AbstractHibernateFactory.java:124)
    at sherlock.common.service.BatchServiceImpl.log(BatchServiceImpl.java:148)
    at sherlock.common.service.BatchServiceImpl.log(BatchServiceImpl.java:128)
    at sherlock.plugin.imports.CompanyImportPlugin.executePlugin(CompanyImportPlugin.java:184)
    at sherlock.backend.job.AbstractHibernatePlugin.execute(AbstractHibernatePlugin.java:70)
    at sherlock.backend.job.AbstractPluginJobTask.run(AbstractPluginJobTask.java:180)
    at framework.util.task.TaskEngine$TaskEngineWorker.run(TaskEngine.java:174)Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed.

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
    at com.mysql.jdbc.Util.getInstance(Util.java:384)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
    at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:404)
    at com.mysql.jdbc.PreparedStatement.clearParameters(PreparedStatement.java:1140)
    at com.mysql.jdbc.jdbc2.optional.PreparedStatementWrapper.clearParameters(PreparedStatementWrapper.java:805)
    at com.caucho.sql.UserPreparedStatement.clearParameters(UserPreparedStatement.java:158)
    at com.caucho.sql.UserPreparedStatement.close(UserPreparedStatement.java:724)
    at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:563)
    at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:291)
    at org.hibernate.id.insert.AbstractReturningDelegate.releaseStatement(AbstractReturningDelegate.java:82)
    at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:60)
    ... 21 more
06:44:48 [INFO]: plugin.java:196 - End plugin
06:44:48 [ERROR]: AssertionFailure.java:45 - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null id in sherlock.common.dao.BatchLog entry (don't flush the Session after an exception occurs)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:82)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:190)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:147)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
    at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:88)
    at com.caucho.transaction.TransactionImpl.callBeforeCompletion(TransactionImpl.java:843)
    at com.caucho.transaction.TransactionImpl.commit(TransactionImpl.java:582)
    at com.caucho.transaction.TransactionManagerImpl.commit(TransactionManagerImpl.java:271)
    at com.caucho.jca.UserTransactionImpl.commit(UserTransactionImpl.java:436)
    at com.caucho.jca.UserTransactionProxy.commit(UserTransactionProxy.java:167)
    at sherlock.backend.job.AbstractPluginJobTask.endTransaction(AbstractPluginJobTask.java:126)
    at sherlock.backend.job.AbstractPluginJobTask.run(AbstractPluginJobTask.java:202)
    at framework.util.task.TaskEngine$TaskEngineWorker.run(TaskEngine.java:174)
06:44:48 [ERROR]: AbstractPluginJobTask.java:135 - Couldn't commit!
javax.transaction.RollbackException: org.hibernate.AssertionFailure: null id in sherlock.common.dao.BatchLog entry (don't flush the Session after an exception occurs)
    at com.caucho.transaction.TransactionImpl.callBeforeCompletion(TransactionImpl.java:847)
    at com.caucho.transaction.TransactionImpl.commit(TransactionImpl.java:582)
    at com.caucho.transaction.TransactionManagerImpl.commit(TransactionManagerImpl.java:271)
    at com.caucho.jca.UserTransactionImpl.commit(UserTransactionImpl.java:436)
    at com.caucho.jca.UserTransactionProxy.commit(UserTransactionProxy.java:167)
    at sherlock.backend.job.AbstractPluginJobTask.endTransaction(AbstractPluginJobTask.java:126)
    at sherlock.backend.job.AbstractPluginJobTask.run(AbstractPluginJobTask.java:202)
    at framework.util.task.TaskEngine$TaskEngineWorker.run(TaskEngine.java:174)
Caused by: org.hibernate.AssertionFailure: null id in sherlock.common.dao.BatchLog entry (don't flush the Session after an exception occurs)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:82)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:190)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:147)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
    at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:88)
    at com.caucho.transaction.TransactionImpl.callBeforeCompletion(TransactionImpl.java:843)
    ... 7 more
1
I hope you're using one session per Thread, otherwise you'll get all kinds of errors. The error message is quite clear, Hibernate didn't find an id when it tried to insert a BatchLog object. So probably you have a bug in your code or you have the wrong mapping for the id attribute of that class.Augusto
What do you mean by more useful information? The error message gives you plentySteve
Thank you for helping out. As far as I can see the plugin runs in there own transaction and session the rest of the code runs in a long http transaction. And mapping works most of the time.plweb.se
More useful information would be to print the failing sql. The batchlog is should log be inserted even on errors in the plugin job.plweb.se

1 Answers

0
votes

Not really an answer, but check out: http://community.jboss.org/thread/170092 (if you did not already see that post)