Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Pattern »

Re: concurrency problem

Deepak Nagaraj

2005-04-08

Replies:

Hi Ashwani,

I totally agree with what abhijit has mentioned. Application server
serializes the calls to the Session beans.

It would be ideal case to handle the multiple clicks or simultaneous
clicks in the Action classes. If you are using struts framework, a
feature is already provided to handle it.

With Regards,
Deepak Nagaraj


-----Original Message-----
From: An interest list for Sun Java Center J2EE Pattern Catalog
[mailto:J2EEPATTERNS-INTEREST@(protected)
Sent: Friday, April 08, 2005 5:34 PM
To: J2EEPATTERNS-INTEREST@(protected)
Subject: Re: concurrency problem

Hi Ashwani,

please read below from the EJB spec 2.0 which is old
spec version --

============
EJB 2.0 spec
============
"[6.5.6] Serializing session bean methods
A container serializes calls to each session bean
instance.Most containers will support many instances
of a session bean executing concurrently; however,
each instance sees only a serialized sequence of
method calls. Therefore a session bean does not have
to be coded as reentrant.

The container must serialize all the container-invoked
callbacks (ejbPassivate, beforeCompletion, ...)

Clients are not allowed to make concurrent calls to a
SFSB(Stateful Session Bean).The container must throw a
java.rmi.Exception to the second client.This
restriction does not apply to SLSB(Stateless Session
Bean)."

Please check EJB spec 2.1 if you are using it and
confirm whether this is still valid.

Hope this helps.

Cheers
Abhijeet
BEA Support Engineer

--- "Kalra, Ashwani" <ashwani.kalra@(protected)>
wrote:
>
> I am facing concurrency problem in following
> scenario.
>
>
>
> All our action classes call same stateful session
> bean . Each action class obtains the reference from
> HTTPSession object and calls one and only one
> business method.
>
> To prevent the concurrent access to this instance
> which occurs when user immediately presses two links
> quickly in succession I am using the following code
> block
>
>
>
> execute(...) //execute methods of Action class
>
> {
>
> .....
>
> .....
>
> //Obtain the session from Request.User will always
> be in session here
>
> session=request.getSession()
>
> Synchronised(session)
>
> {
>
> //call ejb's business method.
>
> }
>
>
>
> }
>
> However sometimes more than one thread is able to
> pass through, And I get exception from Appserver. As
> 2 threads are not allowed for statefull Session
> bean.
>
> Can there be problem in above code. Is it ok to
> synchronise on session object.
>
> Thanks & Regds
> Ashwani
>
> Ext: 1860
>
>
>
>
>
>
>
> This message contains information that may be
> privileged or confidential and is the property of
> the Capgemini Group. It is intended only for the
> person to whom it is addressed. If you are not the
> intended recipient, you are not authorized to read,
> print, retain, copy, disseminate, distribute, or
> use this message or any part thereof. If you receive
> this message in error, please notify the sender
> immediately and delete all copies of this message.
>
>
====================================================================
> Companion Site: http://www.corej2eepatterns.com
> J2EE BluePrints:
> http://java.sun.com/blueprints/corej2eepatterns
> List Archive:
>
http://archives.java.sun.com/archives/j2eepatterns-interest.html
> Unsubscribing: email "signoff J2EEPATTERNS-INTEREST"
> to listserv@(protected)
>



__________________________________
Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less.
http://info.mail.yahoo.com/mail_250

====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive:
http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
listserv@(protected)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Information transmitted by this EMAIL is proprietary to iGATE Group of Companies and is intended for use only by the individual
or entity to whom it is addressed and may contain information that is privileged, confidential, or exempt from disclosure under
applicable law. If you are not the intended recipient of this EMAIL immediately notify the sender at iGATE or mailadmin@(protected)
and delete this EMAIL including any attachments
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.