-->
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.  [ 4 posts ] 
Author Message
 Post subject: ConcurrentModificationException occasionally pops up
PostPosted: Fri Jan 23, 2004 12:19 pm 
Beginner
Beginner

Joined: Sat Dec 06, 2003 5:38 pm
Posts: 27
Hi,

Using 2.1.1, I occasionally get a java.util.ConcurrentModificationException:
Quote:
java.util.ConcurrentModificationException
at org.apache.commons.collections.SequencedHashMap$OrderedIterator.next(Unknown Source)
at net.sf.hibernate.util.IdentityMap.entryList(IdentityMap.java:173)
at net.sf.hibernate.util.IdentityMap.entries(IdentityMap.java:58)
at net.sf.hibernate.impl.SessionImpl.flushCollections(SessionImpl.java:2666)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2208)
at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1732)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1499)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1464)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1450)
at org.apache.fulcrum.security.hibernate.HibernateUserManagerImpl.checkExists(HibernateUserManagerImpl.java:95)


In my checkExists function I am doing:
Code:
users = getPersistenceHelper().retrieveSession().find("from " + User.class.getName() + " su where su.name=?", userName, Hibernate.STRING);


This of course is an intermittent problem, and only occassionally occurs.. Any ideas? I am using ehcache 0.6, I am going to bump it to 0.7 just to see...

Eric


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2004 1:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You are modifying the collection somewhere I suppose while still iterating over it.


Top
 Profile  
 
 Post subject: CRASH BUG in debug output when printing empty collection!
PostPosted: Fri Jan 23, 2004 2:55 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
We have found that Hibernate crashes when its logging level is set to debug and we create an object with a bunch of empty collections. Changing the logging level to info avoids the crash.

Here are the details:

We are trying to create a data model we designed yesterday. The central object is a Campaign object which has four collections: a set of SourceLists, a set of CampaignLists, a set of JobDescriptions, and a set of WorkRequests.

Using good test-driven development, we have a test case:


public void testCreateClient () throws HibernateException {
SessionFactory factory = PersistenceManager.sessionFactory();

Session session = factory.openSession();

// null set
Set n = new HashSet();
//
Client client = new Client("test", n);
session.save(client);
//

Campaign campaign = new Campaign("test1", client, n, n, n, n);

client.getCampaigns().add(campaign);

// session.save(campaign);

session.flush();
session.close();
}


We were running with this log4j.properties:


### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.rootLogger=debug,stdout


When we run this test case, we get:


net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.nimblefish.core.dao.SourceList.id at
net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:110) net.sf.hibernate.persister.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:310) net.sf.hibernate.proxy.HibernateProxyHelper.getIdentifier(HibernateProxyHelper.java:50) net.sf.hibernate.type.EntityType.toString(EntityType.java:84)
net.sf.hibernate.type.PersistentCollectionType.toString(PersistentCollectionType.java:81)
net.sf.hibernate.impl.Printer.toString(Printer.java:49)
net.sf.hibernate.impl.Printer.toString(Printer.java:82)
net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2228)
net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2186)
com.nimblefish.core.test.persist.PersistenceManagerTest.testCreateClient(PersistenceManagerTest.java:83)


This is very weird because we haven't *constructed* any SourceList objects *at all*! Hibernate is apparently trying to print the contents of an empty collection, and CGLIB is trying to wrap a null object and print it?!

If we change log4j.properties like so:


log4j.rootLogger=info,stdout


then the exception DOES NOT HAPPEN.

Here's the section of the fatal debug output:


10:29:43,195 DEBUG SessionImpl:2768 - Collection found: [com.nimblefish.core.dao.Campaign.sourceLists#1], was: [<unreferenced>]
10:29:43,195 DEBUG SessionImpl:2768 - Collection found: [com.nimblefish.core.dao.Campaign.campaignLists#1], was: [<unreferenced>]
10:29:43,195 DEBUG SessionImpl:2768 - Collection found: [com.nimblefish.core.dao.Campaign.workRequests#1], was: [<unreferenced>]
10:29:43,195 DEBUG SessionImpl:2768 - Collection found: [com.nimblefish.core.dao.Campaign.jobDescriptions#1], was: [<unreferenced>]
10:29:43,210 DEBUG SessionImpl:2664 - Processing unreferenced collections
10:29:43,210 DEBUG SessionImpl:2678 - Scheduling collection removes/(re)creates/updates
10:29:43,210 DEBUG SessionImpl:2217 - Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
10:29:43,210 DEBUG SessionImpl:2222 - Flushed: 5 (re)creations, 0 updates, 0 removals to 5 collections
10:29:43,210 DEBUG Printer:75 - listing entities:
10:29:43,226 ERROR BasicPropertyAccessor:106 - IllegalArgumentException in class: com.nimblefish.core.dao.SourceList, getter method of property: id


Here are the mappings:


<?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.nimblefish.core.dao.Client">

<id name="id" type="long" unsaved-value="null" >
<generator class="native"/>
</id>

<property name="name" type="string"/>

<set name="campaigns" inverse="true" cascade="all">
<key column="client_id"/>
<one-to-many class="com.nimblefish.core.dao.Campaign"/>
</set>
</class>

<class name="com.nimblefish.core.dao.Campaign">

<id name="id" type="long" unsaved-value="null" >
<generator class="native"/>
</id>

<property name="name" type="string"/>

<many-to-one name="client" column="client_id" not-null="true"
class="com.nimblefish.core.dao.Client"/>

<set name="sourceLists" inverse="true" cascade="all">
<key column="campaign_id"/>
<one-to-many class="com.nimblefish.core.dao.SourceList"/>
</set>

<set name="campaignLists" inverse="true" cascade="all">
<key column="campaign_id"/>
<one-to-many class="com.nimblefish.core.dao.CampaignList"/>
</set>

<set name="workRequests" inverse="true" cascade="all">
<key column="campaign_id"/>
<one-to-many class="com.nimblefish.core.dao.WorkRequest"/>
</set>

<set name="jobDescriptions" inverse="true" cascade="all">
<key column="campaign_id"/>
<one-to-many class="com.nimblefish.core.dao.JobDescription"/>
</set>

</class>

</hibernate-mapping>


We generated the code for Client.java and Campaign.java using codegen (which didn't complain at all).

This should be fixed :-)

Cheers!
Rob


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2004 2:58 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
Oops! sorry! misposted the above. Reposting now in a new thread. My apologies.

Cheers,
Rob


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