users@glassfish.java.net

Re: Concurrent acess to stateful sb from rich client/design question

From: <glassfish_at_javadesktop.org>
Date: Fri, 12 Oct 2007 13:19:31 PDT

Several points:
<ul><li>I am thick and slow today. Please take anything in here with a block of salt.</li>
<li>I have not used stateful session beans before.</li>
<li>Web applications, unless declared to be single-threaded, have lots of threads plowing through them all the time. Obviously from the standpoint of a programmer, there is usually only one active thread at any point. I mention that because any synchronization issues around shared resources may apply here as well.</li>
<li>It <i>might</i> be sufficient to have your singleton class ensure that all calls to the remote interface are <tt>synchronized</tt> on the reference itself.</li>
<li><tt>ConcurrentModificationExceptions</tt> usually are thrown from <tt>Collections</tt> (or <tt>Iterators</tt>). Nowhere in this post have you mentioned a specific <tt>Collection</tt>, but I'm presuming that's at the root of this? Would wrapping this hypothetical <tt>Collection</tt> with <tt>Collections#synchronizedCollection(Collection)</tt> help?</li>
<li>Riffing on that theme for a moment, I'm going to guess? that perhaps two threads are getting ahold of a <tt>Collection</tt> that is stored in the stateful session bean and are working on it. Recall that you have to synchronize all operations here, including iteration.</li>
</ul>
I hope that helps. Something tells me you've probably tried this.
[Message sent by forum member 'ljnelson' (ljnelson)]

http://forums.java.net/jive/thread.jspa?messageID=239900