Yikes! ConcurrentModificationException [message #384217] |
Thu, 04 December 2008 08:37  |
Eclipse User |
|
|
|
Can something in my code cause this???
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractLi st.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at org.eclipse.persistence.indirection.IndirectList$1.next(Indi rectList.java:546)
at org.eclipse.persistence.internal.queries.InterfaceContainerP olicy.next(InterfaceContainerPolicy.java:226)
at org.eclipse.persistence.internal.queries.ContainerPolicy.nex t(ContainerPolicy.java:701)
at org.eclipse.persistence.mappings.CollectionMapping.cascadeDi scoverAndPersistUnregisteredNewObjects(CollectionMapping.jav a:251)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.c ascadeDiscoverAndPersistUnregisteredNewObjects(ObjectBuilder .java:1489)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.dis coverAndPersistUnregisteredNewObjects(UnitOfWorkImpl.java:37 99)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUni tOfWork.discoverUnregisteredNewObjects(RepeatableWriteUnitOf Work.java:181)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.cal culateChanges(UnitOfWorkImpl.java:584)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.com mitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1320)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUni tOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java: 159)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.com mitAndResume(UnitOfWorkImpl.java:1002)
at org.eclipse.persistence.internal.jpa.transaction.EntityTrans actionImpl.commitInternal(EntityTransactionImpl.java:84)
at org.eclipse.persistence.internal.jpa.transaction.EntityTrans actionImpl.commit(EntityTransactionImpl.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.tbee.util.jpa.EntityTransactionExtender.invoke(EntityTra nsactionExtender.java:106)
at $Proxy36.commit(Unknown Source)
at org.tbee.swing.jpa.JpaObjectNavigatorModel.doSave(JpaObjectN avigatorModel.java:746)
at org.tbee.swing.jpa.JpaObjectNavigatorBar$3.actionPerformed(J paObjectNavigatorBar.java:125)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButto n.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractB utton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultBu ttonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel .java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Bas icButtonListener.java:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticast er.java:272)
at java.awt.Component.processMouseEvent(Component.java:6134)
at javax.swing.JComponent.processMouseEvent(JComponent.java:326 5)
at java.awt.Component.processEvent(Component.java:5899)
at java.awt.Container.processEvent(Container.java:2023)
at java.awt.Component.dispatchEventImpl(Component.java:4501)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container. java:4301)
at java.awt.LightweightDispatcher.processMouseEvent(Container.j ava:3965)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java: 3895)
at java.awt.Container.dispatchEventImpl(Container.java:2067)
at java.awt.Window.dispatchEventImpl(Window.java:2458)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at org.tbee.swing.EventQueue.dispatchEvent(EventQueue.java:83)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDis patchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispat chThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDis patchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread. java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread. java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:12 2)
|
|
|
|
|
|
Re: Yikes! ConcurrentModificationException [message #384229 is a reply to message #384227] |
Thu, 04 December 2008 10:12   |
Eclipse User |
|
|
|
Zooming in on Buyorder... The error is caused by this line:
public void setReindersRelation(nl.reinders.bm.Relation value)
{
if (value == iReindersRelation) return; // optimalisation and prevent looping
nl.reinders.bm.Relation lValue = iReindersRelation;
if (log4j.isDebugEnabled()) log4j.debug("setReindersRelation: " + lValue + " -> " + value);
fireVetoableChange(REINDERSRELATION_PROPERTY_ID, lValue, value);
if (lValue != null) lValue.removeBuyordersWhereIAmReindersRelation( (nl.reinders.bm.Buyorder)this );
iReindersRelation = value;
try {
if (value != null) value.addBuyordersWhereIAmReindersRelation( (nl.reinders.bm.Buyorder)this ); // <----------------------
} catch (RuntimeException e) { iReindersRelation = lValue; throw e; } // restore upon exception
firePropertyChange(REINDERSRELATION_PROPERTY_ID, lValue, value);
}
So, if a buyorder is created, it searches for a specific relation as a default value, sets it and because of the 1-N, that buyorder is also added to the relation's collection.
Zooming in again on Relation:
public void addBuyordersWhereIAmReindersRelation(nl.reinders.bm.Buyorder value)
{
if (value != null && !iBuyordersWhereIAmReindersRelation.contains(value))
{
java.util.List<nl.reinders.bm.Buyorder> lValue = new java.util.ArrayList<nl.reinders.bm.Buyorder>();
lValue.addAll(iBuyordersWhereIAmReindersRelation);
lValue.add(value);
fireVetoableChange(BUYORDERSWHEREIAMREINDERSRELATION_PROPERT Y_ID, java.util.Collections.unmodifiableList(iBuyordersWhereIAmRei ndersRelation), java.util.Collections.unmodifiableList(lValue));
boolean lWasAdded = iBuyordersWhereIAmReindersRelation.add(value); // <----------------------
lValue.remove(value);
firePropertyChange(BUYORDERSWHEREIAMREINDERSRELATION_PROPERT Y_ID, java.util.Collections.unmodifiableList(lValue), java.util.Collections.unmodifiableList(iBuyordersWhereIAmRei ndersRelation));
try {
value.setReindersRelation( (nl.reinders.bm.Relation)this);
} catch (RuntimeException e) { if (lWasAdded) {iBuyordersWhereIAmReindersRelation.remove(value);} throw e; } // restore upon exception
}
}
If the add is commented out, the error does not occur.
For the CME to occur, it must be processing the iBuyordersWhereIAmReindersRelation. In what way will processing the iBuyordersWhereIAmReindersRelation create a new Buyorder instance?
|
|
|
Re: Yikes! ConcurrentModificationException [message #384231 is a reply to message #384229] |
Thu, 04 December 2008 10:59  |
Eclipse User |
|
|
|
Here also I had to revoke to an application level event:
@Override public void postNew(Buyorder e)
{
e.ignoreChanges();
try
{
e.setReindersRelation(Relation.findReindersNetherlands());
}
finally
{
e.registerChanges();
}
}
I really really have to think about that AspectJ approach.
|
|
|
Powered by
FUDForum. Page generated in 0.06087 seconds