-->
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 & net.sf.hibernate.Asser
PostPosted: Wed May 26, 2004 3:49 pm 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
Hi all,

I'm working on JOnAS and Tomcat and a workflow engine called Shark, I use Hibernate 2.1, PostgreSQL 7.3 and encounter a strange problem.

I think that is possible it comes from me, but I can't figure out where.

1)First thing is :
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
at java.util.HashMap$ValueIterator.next(HashMap.java:812)
at net.sf.hibernate.impl.Printer.toString(Printer.java:82)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2228)
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.QueryImpl.list(QueryImpl.java:39)
at net.sf.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:507)
at org.enhydra.shark.instancepersistence.HibernatePersistentManager.getPersistedActivityObject(HibernatePersistentManager.java:1126)
at org.enhydra.shark.instancepersistence.HibernatePersistentManager.getAllValidAssignmentsForResource(HibernatePersistentManager.java:1838)
at org.enhydra.shark.WfResourceImpl.getAssignmentsMap(WfResourceImpl.java:120)
at org.enhydra.shark.WfResourceImpl.getAssignment(WfResourceImpl.java:144)
at org.enhydra.shark.SharkUtilities.getAssignment(SharkUtilities.java:770)
at org.enhydra.shark.WfAssignmentWrapper.getAssignmentImpl(WfAssignmentWrapper.java:252)
at org.enhydra.shark.WfAssignmentWrapper.get_accepted_status(WfAssignmentWrapper.java:214)
at org.enhydra.shark.WfAssignmentWrapper.get_accepted_status(WfAssignmentWrapper.java:189)
at ManualTest.run(ManualTest.java:55)

Mapping for this part is :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<!-- Hibernate Instance Persistent layer mapping definition file
author Vladislav Pernin-->

<hibernate-mapping>

<class name="org.enhydra.shark.instancepersistence.HibernateActivity" table="activities">

<id name="dbId">
<column name="iddb" not-null="true"/>
<generator class="assigned"/>
</id>

<property name="idAct" type="string" access="field">
<column name="id" not-null="true"/>
</property>

<property name="activityDefinitionId">
<column name="activitydefinitionid" not-null="true"/>
</property>

<property name = "processId">
<column name="process" not-null="true"/>
</property>

<property name = "resourceUsername">
<column name="theresource"/>
</property>

<property name = "stateId">
<column name="state" not-null="true"/>
</property>

<property name="blockActivityId">
<column name="blockactivity"/>
</property>

<property name="name">
<column name="name"/>
</property>

<property name="description">
<column name="description"/>
</property>

<property name="priority">
<column name="priority"/>
</property>

<property name="lastStateTime">
<column name="laststatetime"/>
</property>

<property name="accepted" access="field">
<column name="accepted"/>
</property>

<property name="activated" access="field">
<column name="activated"/>
</property>


</class>
Code is :
private HibernateActivity getPersistedActivityObject(String actId, SharkTransaction ti) throws PersistenceException {
try {
for (Iterator it = ((SharkHibernateTransaction)ti).iterator4type("class org.enhydra.shark.instancepersistence.HibernateActivity");
it.hasNext();) {
HibernateActivity hibActivity = (HibernateActivity)it.next();
if (actId.equals(hibActivity.getId()))
return hibActivity;
}
Session s = ((SharkHibernateTransaction)ti).getSession();
Query qActivity = s.createQuery("from HibernateActivity activity where activity.idAct = :keyValueParam");
qActivity.setString("keyValueParam", actId);
HibernateActivity hibActivity = (HibernateActivity) qActivity.uniqueResult();
((SharkHibernateTransaction)ti).read(hibActivity);
return hibActivity;
} catch (Throwable t) {
throw new PersistenceException(t);
}
}
The problem appears at the line where call to uniqueResult is done.

2)Second problem, is related:
net.sf.hibernate.AssertionFailure: Hibernate has a bug processing collections
at net.sf.hibernate.impl.SessionImpl.prepareCollectionForUpdate(SessionImpl.java:2821)
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2774)
at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.java:32)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2474)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2340)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2207)
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.QueryImpl.list(QueryImpl.java:39)
at net.sf.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:507)
at org.enhydra.shark.instancepersistence.HibernatePersistentManager.getProcessRequesterByActId(HibernatePersistentManager.java:1071)
at org.enhydra.shark.instancepersistence.HibernatePersistentManager.restore(HibernatePersistentManager.java:557)
at org.enhydra.shark.instancepersistence.HibernatePersistentManager.getAllValidAssignmentsForResource(HibernatePersistentManager.java:1838)

Code is :
private HibernateProcessRequester getProcessRequesterByActId(String actId,SharkTransaction ti) throws PersistenceException {
try {
for (Iterator it = ((SharkHibernateTransaction)ti).iterator4type("class org.enhydra.shark.instancepersistence.Hibernat
eProcessRequester");
it.hasNext();) {
HibernateProcessRequester hibProcessRequester = (HibernateProcessRequester)it.next();
if (actId.equals(hibProcessRequester.getActRequester()))
return hibProcessRequester;
}
Session s = ((SharkHibernateTransaction)ti).getSession();
Query qProcessRequesterQuery = s.createQuery("from HibernateProcessRequester processRequester where processRequester.actRequester = :keyValueParam");
qProcessRequesterQuery.setString("keyValueParam", actId);
HibernateProcessRequester hibProcessRequester = (HibernateProcessRequester) qProcessRequesterQuery.uniqueResult();
((SharkHibernateTransaction)ti).read(hibProcessRequester);
return hibProcessRequester;
}
catch (Throwable t) {
throw new PersistenceException(t);
}
}

And mappings :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<!-- Hibernate Instance Persistent layer mapping definition file
author Vladislav Pernin-->

<hibernate-mapping>

<class name="org.enhydra.shark.instancepersistence.HibernateProcessRequester" table="processrequesters">

<id name="dbId">
<column name="iddb" not-null="true"/>
<generator class="assigned"/>
</id>

<property name="idPro" type="string" access="field">
<column name="id" not-null="true"/>
</property>

<property name="actRequester">
<column name="activityrequester"/>
</property>

<property name="resRequester">
<column name="resourcerequester"/>
</property>

</class>

</hibernate-mapping>

Help would be really helpful on this one.

Thanks
Vlad


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 4:04 pm 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
And I also have for same code:
net.sf.hibernate.HibernateException: Found shared references to a collection
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2759)
at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.java:32)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2474)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2340)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2207)
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.QueryImpl.list(QueryImpl.java:39)
at net.sf.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:507)
at org.enhydra.shark.instancepersistence.HibernatePersistentManager.getPersistedActivityObject(HibernatePersistentManager.java:1128)
at org.enhydra.shark.instancepersistence.HibernatePersistentManager.getAllValidAssignmentsForResource(HibernatePersistentManager.java:1840)

Wiki, Jira and Forum haven't been helpful to solve that problem, any idea?

Vlad


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 27, 2004 9:57 am 
Regular
Regular

Joined: Thu Feb 05, 2004 6:51 am
Posts: 50
No one has even a small idea, hibernate experts?

Vlad


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 4:36 am 
Beginner
Beginner

Joined: Thu Apr 29, 2004 4:03 pm
Posts: 40
> java.util.ConcurrentModificationException

I think, this is not Hibernate problem, it's java problem.
I had the same error. It occours, when you are travelling through the members of a collection and paralelly trying to add new items:

for example:
for(Iterator i = mycollection.iterator(); i.hasNext(); ) {
mycollection.add(new Object()) // THIS IS ERROR
}

you need to add elements outside of the for cycle.


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.