Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ConcurrentModificationException on remove call on an ejb

5 views
Skip to first unread message

Joel Rolland

unread,
Mar 19, 2003, 4:58:00 AM3/19/03
to
Hi guys,

I'm using weblogic7.0 sp1 and developping with JBuilder8.
The following error appear when i try to remove an ejb. I'm iterating on an
collection of primary key and i try to remove all ejb of this collection
(source code at the bottom).

The same source code is running on weblogic6.1sp2, have you already see this
problem somewhere? Do you know if it's a programming error or an other
thing?

<Mar 19, 2003 10:25:54 AM CET> <Error> <T3Services> <000000> <M&H BOE Engine
ERROR :
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.next(HashMap.java:731)
at
weblogic.ejb20.internal.TxManager.flushModifiedBeans(TxManager.java:292)
at
weblogic.ejb20.manager.BaseEntityManager.flushModifiedBeans(BaseEntityManage
r.java:1626)
at
weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.flushModifiedBeans(RDBMSPer
sistenceManager.java:1945)
at
weblogic.ejb20.manager.BaseEntityManager.cascadeDeleteRemove(BaseEntityManag
er.java:1202)
at weblogic.ejb20.manager.DBManager.remove(DBManager.java:1024)
at
weblogic.ejb20.internal.EntityEJBLocalObject.remove(EntityEJBLocalObject.jav
a:102)
at
com.mh.app.boe.engine.dba.instanceprocess.InstanceProcessBean_n65kai_ELOImpl
.remove(InstanceProcessBean_n65kai_ELOImpl.java:1015)
at
com.mh.app.boe.engine.model.EngineWorker.removeProcess(EngineWorker.java:513
)
at
com.mh.app.boe.engine.model.EngineWorker.modifyProcesses(EngineWorker.java:4
57)
at
com.mh.app.boe.engine.model.EngineWorker.dealEvent(EngineWorker.java:280)
at
com.mh.app.boe.engine.model.EngineWorker.dealEvent(EngineWorker.java:226)
at
com.mh.app.boe.engine.model.EngineWorker.progressInstanceByStep(EngineWorker
.java:402)
at
com.mh.app.boe.engine.model.EngineWorker.progressInstance(EngineWorker.java:
303)
at
com.mh.app.boe.engine.model.EngineWorker.dealEvent(EngineWorker.java:284)
at
com.mh.app.boe.engine.model.EngineWorker.dealEvent(EngineWorker.java:226)
at
com.mh.app.boe.engine.model.EngineWorker.dealEvent(EngineWorker.java:205)
at
com.mh.app.boe.engine.model.EngineBean.dealEvent(EngineBean.java:89)
at
com.mh.app.boe.engine.model.EngineBean_yehaoy_ELOImpl.dealEvent(EngineBean_y
ehaoy_ELOImpl.java:99)
at
com.mh.app.boe.engine.net.EngineControllerEJBBean.dealEvent(EngineController
EJBBean.java:74)
at
com.mh.app.boe.engine.net.EngineControllerEJBBean_agu4tb_EOImpl.dealEvent(En
gineControllerEJBBean_agu4tb_EOImpl.java:262)
at
com.mh.app.boe.engine.net.EngineControllerEJBBean_agu4tb_EOImpl_WLSkel.invok
e(Unknown Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
:114)
at
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
r.java:821)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
0)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
>

Collection precedentProcesses =
process.findPrecedentProcesses(processIdToActivate, stateMachineId);
for (Iterator precedentProcessesIterator = precedentProcesses.iterator();
precedentProcessesIterator.hasNext(); ) {
String precedentProcessId = (String) precedentProcessesIterator.next();

InstanceProcessPK instanceProcessPKToPassivate = new
InstanceProcessPK(instance.getInstanceId(),
processIdToPassivate,instance.getStateMachineId());
InstanceProcess instanceProcessToPassivate =
serviceLocator.getInstanceProcessHome().findByPrimaryKey(instanceProcessPKTo
Passivate);
if (instanceProcessToPassivate != null)
instanceProcessToPassivate.remove(); //exception is thows on this
instruction
}

Thanks in advance,
Joel.

Ryan LeCompte

unread,
Mar 19, 2003, 7:23:19 AM3/19/03
to

Hello Joel,

You should remove your particular bean instance by calling the remove() method
on the Iterator object as opposed to calling the remove() method directly on the
local interface of the entity bean. The latter will generate the ConcurrentModificationException(),
because the underlying collection will be modified while you are iterating through
it, which generates the exception. This is because the collection/iterator is
"fail-safe." Therefore, in your code you would call precedentProcessesIterator.remove()
instead of instanceProcessToPassivate.remove();

Best regards,

Ryan LeCompte
ryanle...@louisiana.edu
http://www.louisiana.edu/~rml7669

>..remove(InstanceProcessBean_n65kai_ELOImpl.java:1015)


> at
>com.mh.app.boe.engine.model.EngineWorker.removeProcess(EngineWorker.java:513
>)
> at
>com.mh.app.boe.engine.model.EngineWorker.modifyProcesses(EngineWorker.java:4
>57)
> at
>com.mh.app.boe.engine.model.EngineWorker.dealEvent(EngineWorker.java:280)
> at
>com.mh.app.boe.engine.model.EngineWorker.dealEvent(EngineWorker.java:226)
> at
>com.mh.app.boe.engine.model.EngineWorker.progressInstanceByStep(EngineWorker

>..java:402)

Ryan LeCompte

unread,
Mar 19, 2003, 7:42:14 AM3/19/03
to

Hello Joel,

After giving your code a second look, it appears that the Collection returned
by your finder method is composed of Strings, and not the actual local interfaces
of the underlying entity beans. Are you sure that there aren't other threads of
execution that are iterating through a collection of InstanceProcesses' while
you are calling the remove() method of the current InstanceProcess in the code
that you wrote?

Best regards,

Joel Rolland

unread,
Mar 19, 2003, 9:51:14 AM3/19/03
to
Hello Ryan,

There are no other threads of execution that try to access to this
collection of InstanceProcess in my code.
Could it be the application server?
Nota: I 'm using transaction managed by container.

Best regards,
Joel.
"Ryan LeCompte" <ryanle...@louisiana.edu> wrote in message
news:3e7865a6$1...@newsgroups.bea.com...

Slava Imeshev

unread,
Mar 19, 2003, 12:46:16 PM3/19/03
to
Hi Joel,

"Joel Rolland" <joel.r...@mhinformatics.com> wrote in message
news:3e78...@newsgroups.bea.com...

> I'm using weblogic7.0 sp1 and developping with JBuilder8.
> The following error appear when i try to remove an ejb. I'm iterating on
an
> collection of primary key and i try to remove all ejb of this collection
> (source code at the bottom).
>
> The same source code is running on weblogic6.1sp2, have you already see
this
> problem somewhere? Do you know if it's a programming error or an other
> thing?
>
> <Mar 19, 2003 10:25:54 AM CET> <Error> <T3Services> <000000> <M&H BOE
Engine
> ERROR :
> java.util.ConcurrentModificationException
> at java.util.HashMap$HashIterator.next(HashMap.java:731)
> at
> weblogic.ejb20.internal.TxManager.flushModifiedBeans(TxManager.java:292)

It looks like a bug in the server. I'd try to contact sup...@bea.com.

Please let us know what the resolution is.

Regards,

Slava Imeshev


Ryan LeCompte

unread,
Mar 19, 2003, 2:30:36 PM3/19/03
to

Hello Raj,

Actually I made a little typo. =) The term is actually "fail-fast" :-)

From Sun documentation:

"The Iterators returned by this class's iterator method are fail-fast: if the
set is modified at any time after the iterator is created, in any way except through
the iterator's own remove method, the iterator will throw a ConcurrentModificationException.
Thus, in the face of concurrent modification, the iterator fails quickly and cleanly,
rather than risking arbitrary, non-deterministic behavior at an undetermined time
in the future"

Best regards,

Raj <raj...@yahoo.com> wrote:
>Joel
>Move the
>Iterator precedentProcessesIterator = precedentProcesses.iterator();
>out of the for loop and use a while(precedentProcessesIterator.hasNext())
>
>This is because when you removing an instance from the collection, its
>still
>attached to it and the next iteration would do a precedentProcessor.iterator().
>
>As Ryan said, since its failsafe, it will throw this Concurrentmodificatione
>xception.
>
>-Raj

Raj

unread,
Mar 19, 2003, 2:13:49 PM3/19/03
to
Joel
Move the
Iterator precedentProcessesIterator = precedentProcesses.iterator();
out of the for loop and use a while(precedentProcessesIterator.hasNext())

This is because when you removing an instance from the collection, its still
attached to it and the next iteration would do a precedentProcessor.iterator().

As Ryan said, since its failsafe, it will throw this Concurrentmodificatione
xception.

-Raj

Joel Rolland

unread,
Mar 21, 2003, 6:20:10 AM3/21/03
to
Raj,
I have tryed your modifications but it's always the same result.
I don't think that the exception is throw from my collection because there
are no reaon that weblogic modify my collection of string (ejb id) when
weblogic remove the ejb.

Joel.

"Raj" <raj...@yahoo.com> wrote in message
news:3E78C16D...@yahoo.com...

Ryan LeCompte

unread,
Mar 23, 2003, 10:14:40 PM3/23/03
to

Hello Joel,

Have you solved your problem yet? What transaction level are you utilizing for
your EJBs? Can you try, instead of iterating over Strings, iterate over the actual
EJB local object instances and try removing elements via the iterator's remove()
method? Try different scenarios and let us know if you continue getting this error.
Also, try upgrading to WLS 7.0 SP2.

Best regards,

0 new messages