You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Michael Watson <mi...@estafet.com> on 2003/10/08 18:31:15 UTC
ConcurrentModificationException
Hi all,
I'm finding I quite reguarly get this exception when I'm attempting to call
PersistenceBroker.store(Object) from multiple threads simultaneously.
<?xml version='1.0'?>
<exception>
<cause>
<detailMessage/>
<exceptionClass>java.util.ConcurrentModificationException</exceptionClass>
<stackTrace>
<stackTrace>java.util.AbstractList$Itr.checkForComodification(AbstractList.j
ava:444)</stackTrace>
<stackTrace>java.util.AbstractList$Itr.next(AbstractList.java:417)</stackTra
ce>
<stackTrace>java.util.AbstractCollection.remove(AbstractCollection.java:250)
</stackTrace>
<stackTrace>org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown
Source)</stackTrace>
<stackTrace>org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown
Source)</stackTrace>
<stackTrace>org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unk
nown Source)</stackTrace>
...
</stackTrace>
</cause>
<detailMessage>Failed to update History record
java.util.ConcurrentModificationException</detailMessage>
<exceptionClass>org.apache.ojb.broker.PersistenceBrokerException</exceptionC
lass>
<stackTrace/>
</exception>
Obviously somewhere in the broker there's been an attempt to modify the
structure of a list by 2 or more threads simultaneously.
My question is, has anything been done to prevent this in a newer version or
should I just catch these exceptions and retry the store?
I'm using ojb-1.0.rc3 at the moment.
Regards,
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: ConcurrentModificationException
Posted by Michael Watson <mi...@estafet.com>.
Hi Armin,
I have an object with an init method where I assign a PersistenceBroker
instance using
PersistenceBrokerFactory.defaultPersistenceBroker()
This object then has an onEvent() method that is called and uses
broker.store().
I tried modifying the object so that the broker is obtained in the onEvent
instead of the init and I started getting
"Borrow broker from pool failed" Exceptions. I have my connection-pool set
up as follows:
<connection-pool maxActive="-1" whenExhaustedAction="2"
validationQuery="select 1 from t_client"/>
Do you have any suggestions for what I might be doing wrong?
Mike
----- Original Message -----
From: "Armin Waibel" <ar...@code-au-lait.de>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Wednesday, October 08, 2003 6:02 PM
Subject: Re: ConcurrentModificationException
> Hi Michael,
>
> On Wed, 8 Oct 2003 17:31:15 +0100, Michael Watson
> <mi...@estafet.com> wrote:
>
> > Hi all,
> >
> > I'm finding I quite reguarly get this exception when I'm attempting to
> > call
> > PersistenceBroker.store(Object) from multiple threads simultaneously.
> >
> Do several threads share the same PB instance?
> If so, this is not allowed. PB instances are not
> threadsafe itself, but they are pooled so it's no
> performance impact to use a separate PB instance for each thread.
>
> regards,
> Armin
>
> > <?xml version='1.0'?>
> > <exception>
> > <cause>
> > <detailMessage/>
> >
<exceptionClass>java.util.ConcurrentModificationException</exceptionClass>
> > <stackTrace>
> >
<stackTrace>java.util.AbstractList$Itr.checkForComodification(AbstractList.j
> > ava:444)</stackTrace>
> >
<stackTrace>java.util.AbstractList$Itr.next(AbstractList.java:417)</stackTra
> > ce>
> >
<stackTrace>java.util.AbstractCollection.remove(AbstractCollection.java:250)
> > </stackTrace>
> >
<stackTrace>org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown
> > Source)</stackTrace>
> >
<stackTrace>org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown
> > Source)</stackTrace>
> >
<stackTrace>org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unk
> > nown Source)</stackTrace>
> > ...
> > </stackTrace>
> > </cause>
> > <detailMessage>Failed to update History record
> > java.util.ConcurrentModificationException</detailMessage>
> >
<exceptionClass>org.apache.ojb.broker.PersistenceBrokerException</exceptionC
> > lass>
> > <stackTrace/>
> > </exception>
> >
> > Obviously somewhere in the broker there's been an attempt to modify the
> > structure of a list by 2 or more threads simultaneously.
> >
> > My question is, has anything been done to prevent this in a newer
> > version or
> > should I just catch these exceptions and retry the store?
> >
> > I'm using ojb-1.0.rc3 at the moment.
> >
> > Regards,
> >
> > Mike
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: ConcurrentModificationException
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Michael,
On Wed, 8 Oct 2003 17:31:15 +0100, Michael Watson
<mi...@estafet.com> wrote:
> Hi all,
>
> I'm finding I quite reguarly get this exception when I'm attempting to
> call
> PersistenceBroker.store(Object) from multiple threads simultaneously.
>
Do several threads share the same PB instance?
If so, this is not allowed. PB instances are not
threadsafe itself, but they are pooled so it's no
performance impact to use a separate PB instance for each thread.
regards,
Armin
> <?xml version='1.0'?>
> <exception>
> <cause>
> <detailMessage/>
> <exceptionClass>java.util.ConcurrentModificationException</exceptionClass>
> <stackTrace>
> <stackTrace>java.util.AbstractList$Itr.checkForComodification(AbstractList.j
> ava:444)</stackTrace>
> <stackTrace>java.util.AbstractList$Itr.next(AbstractList.java:417)</stackTra
> ce>
> <stackTrace>java.util.AbstractCollection.remove(AbstractCollection.java:250)
> </stackTrace>
> <stackTrace>org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown
> Source)</stackTrace>
> <stackTrace>org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown
> Source)</stackTrace>
> <stackTrace>org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unk
> nown Source)</stackTrace>
> ...
> </stackTrace>
> </cause>
> <detailMessage>Failed to update History record
> java.util.ConcurrentModificationException</detailMessage>
> <exceptionClass>org.apache.ojb.broker.PersistenceBrokerException</exceptionC
> lass>
> <stackTrace/>
> </exception>
>
> Obviously somewhere in the broker there's been an attempt to modify the
> structure of a list by 2 or more threads simultaneously.
>
> My question is, has anything been done to prevent this in a newer
> version or
> should I just catch these exceptions and retry the store?
>
> I'm using ojb-1.0.rc3 at the moment.
>
> Regards,
>
> Mike
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org