I have a SessionBean that has a method that calls a find method.
In the logic of this method it iterates through the collection returned from the find
method, and calls remove() on some of the ejbs.
This works fine if only one thread calls the method, but if several threads call the
method at the same time it fails.
>From the log I can see that one thread calls .remove on an ejb and it is successfully
>removed from the database.
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.BackEJB] Executing SQL:
DELETE FROM BackEJB WHERE id=?
2002-09-02 10:34:54,482 DEBUG
[org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.BackEJB] Remove: Rows affected
= 1
How ever then in the second thread, the now removed bean is also returned from the
Iterator and when it tries to remove the bean an exception is thrown.
2002-09-02 10:34:54,732 ERROR [org.jboss.ejb.GlobalTxEntityMap] Store failed on
entity: 3631
javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0id=3631
at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:102)
at
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:589)
at
org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:458)
at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity(CachedConnectionInterceptor.java:388)
at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:705)
at org.jboss.ejb.GlobalTxEntityMap.syncEntities(GlobalTxEntityMap.java:99)
at
org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction(EntityContainer.java:172)
at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:503)
at sun.reflect.GeneratedMethodAccessor196.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1170)
at
org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:95)
at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:308)
at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:152)
at
org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
at
org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:203)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
at
org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:301)
at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
at $Proxy247.remove(Unknown Source)
Am I doing some thing wrong? Is there a thread safe way of doing this or is it a bug
in jboss. (Some thing that I find hard to believe no one else would have run into.)
I am willing to provide a simple test case in code if any one is interested.
Any help gratefully received.
Collection theCollection = AHome.findBestAs(new Integer(5));
if (theCollection.size() != 0 ) {
java.util.Iterator i = theCollection.iterator();
while (i.hasNext()) {
BeanALocal theBean = (BeanALocal)i.next();
theBean.remove();
}
}
__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now!
http://channels.netscape.com/ns/browsers/download.jsp
Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user