-->
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.  [ 8 posts ] 
Author Message
 Post subject: ConcurrentModificationException - any ideas?
PostPosted: Fri Dec 26, 2003 3:41 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 1:46 pm
Posts: 20
Hi,

Has anyone ever seen an exception like this?

Canyou tell me what might be some possible causes for this kind of exception?

Thanks,
-Ben

java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:440)
at java.util.AbstractList$Itr.remove(AbstractList.java:425)
at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:498)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:623)
at com.ditech.util.HibernateUtil.openSession(HibernateUtil.java:1082)
at com.ditech.extractionframework.db.Section32Db.searchEmptyLoans(Section32Db.java:175)
at com.ditech.extractionframework.ejb.Section32Bean.updateSection32(Section32Bean.java:60)
at com.ditech.extractionframework.ejb.Section32Bean.execute(Section32Bean.java:168)
at org.quartz.core.JobRunShell.run(JobRunShell.java:147)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:386)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 4:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
It normally happens in two cases:

1. multiple threads accessing/mutating on the same collection

2. mutating a list while iteratin a list.


#1 is probably not the case here, since it looks like it is a problem in a internal list in configuration.

#2 is unlikely - but probably the reason...but we can't help unless you e.g. show the mapping, tell what version it is etc.


ps. have you tried to do it with the latest version ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 10:02 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 1:46 pm
Posts: 20
Thanks for the reply Max.

Are there related bug fixes?

We're using Hibernate v. 2.0.3, I believe.

are there FAQ topics or threads that I can read relating to these two issues?

This code is using multiple threads to update two different databases.

It is using sessions from two different session factories, however.

I'd post the mappings and code, but this is part of a common Enterprise wide back-end that many applications are sharing. So there would be too many files to post.

The immediate files are very basic and simple:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.ditech.extractionframework.db.Section32DbBean" table="EXT_FWORK_OWNER.Section32">
<id name="loanNumber" type="string" column="loan_no" >
<generator class="assigned" />
</id>

<property name="apr" column="apr" type="float" />
<property name="yieldSpread" column="yield_spread" type="double" />
<property name="section32Flag" column="section32_flag" type="string" />
<property name="description" column="description" type="string" />
<property name="dirtyFlag" column="dirty_flag" type="string" />

<property name="lastUpdate" column="last_update" type="timestamp" />

</class>
</hibernate-mapping>

public static List searchEmptyLoans(String aDatasource) throws DataAccessObjectException {

if (log.isTraceEnabled()) {
log.trace("searchEmptyLoans: visited");
}

StringBuffer queryStr = new StringBuffer("Select Section32.loanNumber ");
queryStr.append(BASE_QUERY_STR);
queryStr.append(" where Section32.dirtyFlag = 'Y'");
if (log.isDebugEnabled()) {
log.debug("searchEmptyLoans: query: " + queryStr);
}
Session session = HibernateUtil.openSession(aDatasource);
List results = HibernateUtil.iterate(session, queryStr.toString());
HibernateUtil.close(session);

if (log.isTraceEnabled()) {
log.trace("searchEmptyLoans: end");
}

return results;
}

methods openSession(), iterate(), and close() are just wrapper methods around the Hibernate calls.

Thanks in advance, and any suggested resources or reads would be appreciated.

-Ben


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 10:29 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
There was a bugfix in Hibernate 2.1 which fixed one of CocurrentMoficiationExceptions. But that issue was related to collections of proxies classes. And this is definitely not your case.

Also, I do not think Max is right here because from exception stack trace it looks like Hibernate fails somewhere in the configuration code. This is not about collections. (Well, it is not about Hibernate collections. Java Collections framework is involved of course).

I would suggest you trying Hibernate 2.1 first because it is possible this problem is already fixed.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 10:32 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Pls, show how do you manipulate factories (I suppose it is HibernateUtil.openSession)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2003 10:46 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 1:46 pm
Posts: 20
Thanks for the replies.

It appears it was a synchronization issue.

The code to create the Session Factories was not properly synchronized.

This has been fixed and appears to be working.

Thanks for the help!

-Ben


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 27, 2003 2:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
There was a bugfix in Hibernate 2.1 which fixed one of CocurrentMoficiationExceptions.


Note that this was a fix for a bug that was only introduced in an earlier beta of 2.1. There are no known ConcurrentModificationException bugs that affect either 2.0.x or 2.1.x.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 27, 2003 6:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dimas wrote:
Also, I do not think Max is right here because from exception stack trace it looks like Hibernate fails somewhere in the configuration code. This is not about collections. (Well, it is not about Hibernate collections. Java Collections framework is involved of course).

I would suggest you trying Hibernate 2.1 first because it is possible this problem is already fixed.


I *meant* java.util.Collection's, not Hibernates collections ;)

And bliu_ditech, if your application is so big that you cannot pinpoint the problem then we will have a hard time helping ya' ;)

Especially since the error then most likely is at your side because of the higher complexity. Please try to reproduce the error in a SMALL test program. This should not be hard if the problem is consistently failing. Is it failing everytime ?

_________________
Max
Don't forget to rate


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