-->
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.  [ 2 posts ] 
Author Message
 Post subject: IndexOutOfBoundsException being thrown during a flush/commit
PostPosted: Thu Sep 29, 2005 7:55 am 
Newbie

Joined: Thu Sep 29, 2005 7:15 am
Posts: 2
Hi,

I am using session.replicate() to put an object graph into our Oracle database, but when either flush() or commit() are called I get the following stack trace:

Code:
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
   at java.util.ArrayList.RangeCheck(ArrayList.java:507)
   at java.util.ArrayList.get(ArrayList.java:324)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:488)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:435)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:126)
   at com.db.gto.tms.agr.util.batchProcessing.processors.DelegatingHibernateProcessor.process(DelegatingHibernateProcessor.java:99)
   at com.db.gto.tms.agr.util.batchProcessing.processors.SimpleBatchToucher.process(SimpleBatchToucher.java:109)
   at com.db.gto.tms.agr.util.batchProcessing.processors.BatchProcessor.run(BatchProcessor.java:145)
   at java.lang.Thread.run(Thread.java:534)


I am using Hibernate 3.0 (and tested 3.1Beta3) and by debugging this sequence I can see that the method executeActions(List list) of the class org.hibernate.engine.ActionQueue is altering the length of the ArrayList during the loop which accesses each element in the ArrayList. This throws the exception.

Code:
   private void executeActions(List list) throws HibernateException {
      int size = list.size();
      for ( int i = 0; i < list.size(); i++ ) {
         execute( (Executable) list.get(i) );
      }
      list.clear();
      session.getBatcher().executeBatch();
   }


I altered the expression in the for loop shown above from "for ( int i = 0; i < size; i++ )" to "for ( int i = 0; i < list.size(); i++ )" and this solves the problem.

I believe that the Executable being run is the EntityUpdateAction and that deeper down the clearFromFlushNeededCheck(int) method of ActionQueue is being called which calls updates.clear() possibly causing the problem with the size of the ArrayList. It only ever happens when the number of updates needed is greater than one.

Its quite possible that my mapping files are causing the problem, but there are quite a lot and I am using the Spring framework (version 1.2.1) to manage the Hibernate access and the transactions so the code surrounding the call is spread through many classes.

You're welcome to see any files you need to see, but initially I'll just attach the output of the start of the replication through to the stack trace. It would have been the full debug, but I wasn't allowed to submit it on the grounds that its too large!.

Thanks and best wishes,

John Plaxton

Code:
Thread-23 INFO 2005-09-28 11:17:31,492 com.db.gto.tms.agr.dao.RelationalDAO putAsBean started
Thread-23 INFO 2005-09-28 11:17:31,523 com.db.gto.tms.agr.dao.types.BetterHibernateTemplate$ReplicationCallBack ------ Replicate: ApplicationBean=com.db.gto.tms.agr.bean.model.ApplicationBean - OVERWRITE
Thread-23 DEBUG 2005-09-28 11:17:31,539 org.hibernate.jdbc.AbstractBatcher select APP_ID from VH_APP where APP_ID =?
Thread-23 DEBUG 2005-09-28 11:17:31,539 org.hibernate.jdbc.AbstractBatcher select APP_ID from VH_APP where APP_ID =?
Thread-23 DEBUG 2005-09-28 11:17:31,539 org.hibernate.jdbc.AbstractBatcher select APP_ID from VH_APP where APP_ID =?
Thread-23 DEBUG 2005-09-28 11:17:31,554 org.hibernate.jdbc.AbstractBatcher select INS_ID from VH_INS where INS_ID =?
Thread-23 DEBUG 2005-09-28 11:17:31,554 org.hibernate.jdbc.AbstractBatcher select INS_ID from VH_INS where INS_ID =?
Thread-23 DEBUG 2005-09-28 11:17:31,554 org.hibernate.jdbc.AbstractBatcher select INS_ID from VH_INS where INS_ID =?
Thread-23 DEBUG 2005-09-28 11:17:31,570 org.hibernate.jdbc.AbstractBatcher select INS_BUSINESSUSAGE_ID from VH_INS_BUSINESSUSAGE where INS_BUSINESSUSAGE_ID =?
Thread-23 DEBUG 2005-09-28 11:17:31,570 org.hibernate.jdbc.AbstractBatcher select INS_BUSINESSUSAGE_ID from VH_INS_BUSINESSUSAGE where INS_BUSINESSUSAGE_ID =?
Thread-23 DEBUG 2005-09-28 11:17:31,570 org.hibernate.jdbc.AbstractBatcher select INS_BUSINESSUSAGE_ID from VH_INS_BUSINESSUSAGE where INS_BUSINESSUSAGE_ID =?
Thread-23 INFO 2005-09-28 11:17:31,601 com.db.gto.tms.agr.dao.types.BetterHibernateTemplate$ReplicationCallBack Session is dirty
Thread-23 DEBUG 2005-09-28 11:17:31,617 org.hibernate.jdbc.AbstractBatcher update VH_APP set IS_APPROVED=?, IS_DELETED=?, APP_DESCRIPTION=?, DESKTOPAPP_ID=?, LAST_UPDATE_PERSON_ID=?, LAST_UPDATE_TIMESTAMP=?, LIFESTATUS_ID=?, LOTUSAPP_ID=?, APP_NAME=?, THIRDPARTYAPP_ID=? where APP_ID=?
Thread-23 DEBUG 2005-09-28 11:17:31,617 org.hibernate.jdbc.AbstractBatcher update VH_APP set IS_APPROVED=?, IS_DELETED=?, APP_DESCRIPTION=?, DESKTOPAPP_ID=?, LAST_UPDATE_PERSON_ID=?, LAST_UPDATE_TIMESTAMP=?, LIFESTATUS_ID=?, LOTUSAPP_ID=?, APP_NAME=?, THIRDPARTYAPP_ID=? where APP_ID=?
Thread-23 DEBUG 2005-09-28 11:17:31,617 org.hibernate.jdbc.AbstractBatcher update VH_APP set IS_APPROVED=?, IS_DELETED=?, APP_DESCRIPTION=?, DESKTOPAPP_ID=?, LAST_UPDATE_PERSON_ID=?, LAST_UPDATE_TIMESTAMP=?, LIFESTATUS_ID=?, LOTUSAPP_ID=?, APP_NAME=?, THIRDPARTYAPP_ID=? where APP_ID=?
Thread-23 DEBUG 2005-09-28 11:17:31,617 org.hibernate.jdbc.AbstractBatcher select desktopapp0_.DESKTOPAPP_ID as DESKTOPAPP1_, desktopapp0_.DESKTOPAPP_NAME as DESKTOPAPP2_46_, desktopapp0_.SORTORDER as SORTORDER46_ from VH_DESKTOPAPP desktopapp0_
Thread-23 DEBUG 2005-09-28 11:17:31,617 org.hibernate.jdbc.AbstractBatcher select desktopapp0_.DESKTOPAPP_ID as DESKTOPAPP1_, desktopapp0_.DESKTOPAPP_NAME as DESKTOPAPP2_46_, desktopapp0_.SORTORDER as SORTORDER46_ from VH_DESKTOPAPP desktopapp0_
Thread-23 DEBUG 2005-09-28 11:17:31,617 org.hibernate.jdbc.AbstractBatcher select desktopapp0_.DESKTOPAPP_ID as DESKTOPAPP1_, desktopapp0_.DESKTOPAPP_NAME as DESKTOPAPP2_46_, desktopapp0_.SORTORDER as SORTORDER46_ from VH_DESKTOPAPP desktopapp0_
Thread-23 DEBUG 2005-09-28 11:17:31,633 org.hibernate.jdbc.AbstractBatcher select lifestatus0_.LIFESTATUS_ID as LIFESTATUS1_, lifestatus0_.LIFESTATUS_NAME as LIFESTATUS2_48_, lifestatus0_.SORTORDER as SORTORDER48_ from VH_LIFESTATUS lifestatus0_
Thread-23 DEBUG 2005-09-28 11:17:31,633 org.hibernate.jdbc.AbstractBatcher select lifestatus0_.LIFESTATUS_ID as LIFESTATUS1_, lifestatus0_.LIFESTATUS_NAME as LIFESTATUS2_48_, lifestatus0_.SORTORDER as SORTORDER48_ from VH_LIFESTATUS lifestatus0_
Thread-23 DEBUG 2005-09-28 11:17:31,633 org.hibernate.jdbc.AbstractBatcher select lifestatus0_.LIFESTATUS_ID as LIFESTATUS1_, lifestatus0_.LIFESTATUS_NAME as LIFESTATUS2_48_, lifestatus0_.SORTORDER as SORTORDER48_ from VH_LIFESTATUS lifestatus0_
Thread-23 DEBUG 2005-09-28 11:17:31,648 org.hibernate.jdbc.AbstractBatcher select lotusappli0_.LOTUSAPP_ID as LOTUSAPP1_, lotusappli0_.LOTUSAPP_NAME as LOTUSAPP2_49_, lotusappli0_.SORTORDER as SORTORDER49_ from VH_LOTUSAPP lotusappli0_
Thread-23 DEBUG 2005-09-28 11:17:31,648 org.hibernate.jdbc.AbstractBatcher select lotusappli0_.LOTUSAPP_ID as LOTUSAPP1_, lotusappli0_.LOTUSAPP_NAME as LOTUSAPP2_49_, lotusappli0_.SORTORDER as SORTORDER49_ from VH_LOTUSAPP lotusappli0_
Thread-23 DEBUG 2005-09-28 11:17:31,648 org.hibernate.jdbc.AbstractBatcher select lotusappli0_.LOTUSAPP_ID as LOTUSAPP1_, lotusappli0_.LOTUSAPP_NAME as LOTUSAPP2_49_, lotusappli0_.SORTORDER as SORTORDER49_ from VH_LOTUSAPP lotusappli0_
Thread-23 DEBUG 2005-09-28 11:17:31,664 org.hibernate.jdbc.AbstractBatcher select thirdparty0_.THIRDPARTYAPP_ID as THIRDPAR1_, thirdparty0_.THIRDPARTYAPP_NAME as THIRDPAR2_50_, thirdparty0_.SORTORDER as SORTORDER50_ from VH_THIRDPARTYAPP thirdparty0_
Thread-23 DEBUG 2005-09-28 11:17:31,664 org.hibernate.jdbc.AbstractBatcher select thirdparty0_.THIRDPARTYAPP_ID as THIRDPAR1_, thirdparty0_.THIRDPARTYAPP_NAME as THIRDPAR2_50_, thirdparty0_.SORTORDER as SORTORDER50_ from VH_THIRDPARTYAPP thirdparty0_
Thread-23 DEBUG 2005-09-28 11:17:31,664 org.hibernate.jdbc.AbstractBatcher select thirdparty0_.THIRDPARTYAPP_ID as THIRDPAR1_, thirdparty0_.THIRDPARTYAPP_NAME as THIRDPAR2_50_, thirdparty0_.SORTORDER as SORTORDER50_ from VH_THIRDPARTYAPP thirdparty0_
Thread-23 ERROR 2005-09-28 11:17:31,679 com.db.gto.tms.agr.dao.types.BetterHibernateTemplate$ReplicationCallBack java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
Thread-23 INFO 2005-09-28 11:17:31,679 com.db.gto.tms.agr.dao.types.BetterHibernateTemplate$ReplicationCallBack ------ Replicate: Done!
Thread-23 INFO 2005-09-28 11:17:31,679 com.db.gto.tms.agr.dao.RelationalDAO putAsBean done
Thread-23 DEBUG 2005-09-28 11:17:31,695 org.hibernate.jdbc.AbstractBatcher update VH_INS set ACTUAL_RETIRE_DATE=?, IS_APPROVED=?, APP_ID=?, IS_DELETED=?, INS_COUNT=?, INS_SPECIFIC_NAME=?, INVESTMENTSTRATEGY_ID=?, LIFESTATUS_ID=?, APP_INS_NAME=?, ORIGINAL_PLAN_RETIRE_DATE=?, PLAN_RETIRE_DATE=?, SOLDCOMPANY=?, VERSION=?, IS_DBRAMM_REQUIRED=? where INS_ID=?
Thread-23 DEBUG 2005-09-28 11:17:31,695 org.hibernate.jdbc.AbstractBatcher update VH_INS set ACTUAL_RETIRE_DATE=?, IS_APPROVED=?, APP_ID=?, IS_DELETED=?, INS_COUNT=?, INS_SPECIFIC_NAME=?, INVESTMENTSTRATEGY_ID=?, LIFESTATUS_ID=?, APP_INS_NAME=?, ORIGINAL_PLAN_RETIRE_DATE=?, PLAN_RETIRE_DATE=?, SOLDCOMPANY=?, VERSION=?, IS_DBRAMM_REQUIRED=? where INS_ID=?
Thread-23 DEBUG 2005-09-28 11:17:31,695 org.hibernate.jdbc.AbstractBatcher update VH_INS set ACTUAL_RETIRE_DATE=?, IS_APPROVED=?, APP_ID=?, IS_DELETED=?, INS_COUNT=?, INS_SPECIFIC_NAME=?, INVESTMENTSTRATEGY_ID=?, LIFESTATUS_ID=?, APP_INS_NAME=?, ORIGINAL_PLAN_RETIRE_DATE=?, PLAN_RETIRE_DATE=?, SOLDCOMPANY=?, VERSION=?, IS_DBRAMM_REQUIRED=? where INS_ID=?
Thread-23 DEBUG 2005-09-28 11:17:31,711 org.hibernate.jdbc.AbstractBatcher select investment0_.INVESTMENTSTRATEGY_ID as INVESTME1_, investment0_.INVESTMENTSTRATEGY_NAME as INVESTME2_47_, investment0_.SORTORDER as SORTORDER47_ from VH_INVESTMENTSTRATEGY investment0_
Thread-23 DEBUG 2005-09-28 11:17:31,711 org.hibernate.jdbc.AbstractBatcher select investment0_.INVESTMENTSTRATEGY_ID as INVESTME1_, investment0_.INVESTMENTSTRATEGY_NAME as INVESTME2_47_, investment0_.SORTORDER as SORTORDER47_ from VH_INVESTMENTSTRATEGY investment0_
Thread-23 DEBUG 2005-09-28 11:17:31,711 org.hibernate.jdbc.AbstractBatcher select investment0_.INVESTMENTSTRATEGY_ID as INVESTME1_, investment0_.INVESTMENTSTRATEGY_NAME as INVESTME2_47_, investment0_.SORTORDER as SORTORDER47_ from VH_INVESTMENTSTRATEGY investment0_
Thread-23 ERROR 2005-09-28 11:17:31,742 com.db.gto.tms.agr.util.batchProcessing.processors.DelegatingHibernateProcessor process failed: Index: 1, Size: 0
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
   at java.util.ArrayList.RangeCheck(ArrayList.java:507)
   at java.util.ArrayList.get(ArrayList.java:324)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:488)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:435)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:126)
   at com.db.gto.tms.agr.util.batchProcessing.processors.DelegatingHibernateProcessor.process(DelegatingHibernateProcessor.java:99)
   at com.db.gto.tms.agr.util.batchProcessing.processors.SimpleBatchToucher.process(SimpleBatchToucher.java:109)
   at com.db.gto.tms.agr.util.batchProcessing.processors.BatchProcessor.run(BatchProcessor.java:145)
   at java.lang.Thread.run(Thread.java:534)
Thread-23 INFO 2005-09-28 11:17:31,758 com.db.gto.tms.agr.util.batchProcessing.processors.DelegatingHibernateProcessor process done
Thread-23 INFO 2005-09-28 11:17:31,758 com.db.gto.tms.agr.util.batchProcessing.processors.DelegatingHibernateProcessor CleanUp beginning -- DelegatingHibernateProcessor
Thread-23 INFO 2005-09-28 11:17:31,758 com.db.gto.tms.agr.util.batchProcessing.processors.DelegatingHibernateProcessor Closing single Hibernate session in DelegatingHibernateProcessor
Thread-23 INFO 2005-09-28 11:17:31,773 com.db.gto.tms.agr.util.batchProcessing.processors.DelegatingHibernateProcessor CleanUp ending -- DelegatingHibernateProcessor


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 4:53 pm 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Hi,
we are facing the same issue here. We have tracked it down to the following:

http://forum.hibernate.org/viewtopic.php?t=955629

Maybe you found a solution to the issue. If yes, please post it here!


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