When I run my application with single thread, it is going fine. When I am testing the same application with multiple users using Load Runner for performance testing, I am getting the following error. I am using hibernate 3.0 along with c3p0 connection pooling. Tomcat 5.5.2 is the webserver. db2 8.1 is the version of the database server.
My Sample code is as follows:
saveItems()
{
session = HibernateUtil.getSessionFactory().openSession();
session.setFlushMode(FlushMode.MANUAL);
tx = session.beginTransaction();
//delete the old entries from the database.
List<Item> olditems = dao.findCurrent(account);
for (int i = 0; i < oldItems.size(); i++) {
session.lock(oldItems.get(i), LockMode.UPGRADE);
session.delete(oldItems.get(i));
}
//insert the new entries into the database.
List<Item> newItems = dao.findCurrent(account);
for (int i = 0; i < newItems.size(); i++) {
session.saveOrUpdate(newItems (i));
}
session.flush();
tx.commit();
}
My mapping file is as follows: My item has a mapping file with the child element subitem.
<class name="com.sample.Item" table="item_tbl">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="name" column="name" length="45"/>
<property name="updateDateTime" column="last_modified"/>
<list name="subitems" cascade="all">
<key column="item_id"/>
<index column="row_num"/>
<one-to-many class="com.sample.SubItem"/>
</list>
</class>
<class name="com.sample.SubItem" table="sub_item_tbl">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="name" column="name" length="45"/>
<property name="updateDateTime" column="last_modified"/>
</class>
17:09:37,857 DEBUG JDBCExceptionReporter:63 - could not delete collection: [com.sample.Item.subItems#125777] [update sub_item_tbl set item_id=null, row_num=null where item_id=?]
com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -911, SQLSTATE: 40001, SQLERRMC: 2
at com.ibm.db2.jcc.b.zc.e(zc.java:1606)
at com.ibm.db2.jcc.a.db.t(db.java:748)
at com.ibm.db2.jcc.a.db.l(db.java:398)
at com.ibm.db2.jcc.a.db.a(db.java:64)
at com.ibm.db2.jcc.a.r.a(r.java:48)
at com.ibm.db2.jcc.a.tb.c(tb.java:266)
at com.ibm.db2.jcc.b.ad.Z(ad.java:1666)
at com.ibm.db2.jcc.b.ad.d(ad.java:2224)
at com.ibm.db2.jcc.b.ad.V(ad.java:521)
at com.ibm.db2.jcc.b.ad.executeUpdate(ad.java:504)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1048)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:28)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.sample.Item.saveItems(ItemHandler.java:260)
at com.sample.controller.ItemServlet.doPost(ItemServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.sample.filter.DensoIdFilter.doFilter(DensoIdFilter.java:242)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
17:09:37,857 DEBUG AbstractCollectionPersister:1090 - Inserting collection: [com.sample.Item.subItems#125781]
17:09:37,857 WARN JDBCExceptionReporter:71 - SQL Error: -911, SQLState: 40001
17:09:37,857 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:09:37,857 ERROR JDBCExceptionReporter:72 - DB2 SQL error: SQLCODE: -911, SQLSTATE: 40001, SQLERRMC: 2
17:09:37,857 DEBUG SQL:393 –
update sub_item_tbl set item_id=null, row_num=null where id=?
17:09:37,857 ERROR AbstractFlushingEventListener:300 - Could not synchronize database state with session
org.hibernate.exception.LockAcquisitionException: could not delete collection: [com.sample.Item.subItems #125777]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:82)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1071)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:28)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.sample.ItemHanlder.saveItems(ItemHandler.java:260)
at com.sample.controller.ItemServlet.doPost(ItemServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.sample.filter.DensoIdFilter.doFilter(DensoIdFilter.java:242)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -911, SQLSTATE: 40001, SQLERRMC: 2
at com.ibm.db2.jcc.b.zc.e(zc.java:1606)
at com.ibm.db2.jcc.a.db.t(db.java:748)
at com.ibm.db2.jcc.a.db.l(db.java:398)
at com.ibm.db2.jcc.a.db.a(db.java:64)
at com.ibm.db2.jcc.a.r.a(r.java:48)
at com.ibm.db2.jcc.a.tb.c(tb.java:266)
at com.ibm.db2.jcc.b.ad.Z(ad.java:1666)
at com.ibm.db2.jcc.b.ad.d(ad.java:2224)
at com.ibm.db2.jcc.b.ad.V(ad.java:521)
at com.ibm.db2.jcc.b.ad.executeUpdate(ad.java:504)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1048)
... 28 more
17:09:37,857 DEBUG AbstractBatcher:476 - preparing statement
17:09:37,857 DEBUG ConnectionManager:472 - registering flush end
17:09:37,857 DEBUG LongType:80 - binding '125781' to parameter: 1
17:09:37,857 INFO ItemHandler:265 - Exception in delete ##### Item Name and Acct NumFun00003U5R0G
17:09:37,857 DEBUG IntegerType:80 - binding '0' to parameter: 2
17:09:37,857 INFO ItemHandler:266 - Exception in deleting or persisting the items and subitems
org.hibernate.exception.LockAcquisitionException: could not delete collection: [com.sample.Item.subItems#125777]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:82)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1071)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:28)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.sample.ItemHandler.saveItems(ItemHandler.java:260)
at com.sample.controller.ItemServlet.doPost(ItemServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.sample.filter.DensoIdFilter.doFilter(DensoIdFilter.java:242)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -911, SQLSTATE: 40001, SQLERRMC: 2
at com.ibm.db2.jcc.b.zc.e(zc.java:1606)
at com.ibm.db2.jcc.a.db.t(db.java:748)
at com.ibm.db2.jcc.a.db.l(db.java:398)
at com.ibm.db2.jcc.a.db.a(db.java:64)
at com.ibm.db2.jcc.a.r.a(r.java:48)
at com.ibm.db2.jcc.a.tb.c(tb.java:266)
at com.ibm.db2.jcc.b.ad.Z(ad.java:1666)
at com.ibm.db2.jcc.b.ad.d(ad.java:2224)
at com.ibm.db2.jcc.b.ad.V(ad.java:521)
at com.ibm.db2.jcc.b.ad.executeUpdate(ad.java:504)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1048)
... 28 more
17:09:37,857 DEBUG LongType:80 - binding '775566' to parameter: 3
17:09:37,857 DEBUG JDBCTransaction:152 - rollback
17:09:37,857 DEBUG JDBCTransaction:163 - rolled back JDBC Connection
17:09:37,857 DEBUG AbstractBatcher:222 - reusing prepared statement
17:09:37,857 DEBUG JDBCContext:215 - after transaction completion
17:09:37,857 DEBUG SQL:393 -
update sub_item_tbl set item_id=null, row_num=null where item_id=?
17:09:37,857 DEBUG ConnectionManager:398 - aggressively releasing JDBC connection
I am having the following questions:
1. Do hibernate configuration file has any problems?
2. Is this the problem with db2 database?
Please help me in knowing why this exception is coming. Any pointers towards this error would be greatly appreciated.
Thanks In Advance,
Best Regards,
durga
|