Java Mailing List Archive

http://www.junlu.com/

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

Re: concurrency problem

Glenn Phillips

2005-04-08

Replies:

For what it is worth, try using request.getSession(false) instead. You may
have been running into a situation where you were not synchronizing on a
unique object. I'm not sure which server you are using, but it may be
returning a new session object instance (not logical instance) when there is
an exclusive hold on the prior session instance.

My two cents,

Glenn

>From: "Kalra, Ashwani" <ashwani.kalra@(protected);
>Reply-To: An interest list for Sun Java Center J2EE Pattern Catalog
<J2EEPATTERNS-INTEREST@(protected);
>To: J2EEPATTERNS-INTEREST@(protected)
>Subject: concurrency problem
>Date: Fri, 8 Apr 2005 16:53:22 +0530
>MIME-Version: 1.0
>Received: from swjscmail2.java.sun.com ([192.18.99.108]) by
mc1-f4.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 8 Apr 2005
04:33:53 -0700
>Received: from swjscmail1 (swjscmail1.Sun.COM [192.18.99.107])by
swjscmail2.java.sun.com (Postfix) with ESMTPid 93C7D21548; Fri, 8 Apr 2005
05:25:51 -0600 (MDT)
>Received: from JAVA.SUN.COM by JAVA.SUN.COM (LISTSERV-TCP/IP release
1.8e) with       spool id 60503412 for
J2EEPATTERNS-INTEREST@(protected)
>Received: from mxeorb01.capgemini.com (mxeorb01.capgemini.com
[198.184.232.82])       by swjscmail1.java.sun.com (Postfix) with ESMTP
id EB5F848EC for       <J2EEPATTERNS-INTEREST@(protected),
8 Apr 2005 05:10:04 -0600       (MDT)
>Received: from mxiorb01.capgemini.com (crayfish [205.223.236.82]) by
   mxeorb01.capgemini.com (8.13.3/8.12.11) with ESMTP id j38BNYrK000092
    for <J2EEPATTERNS-INTEREST@(protected)
13:23:34       +0200 (MEST)
>Received: from mxiorb01.capgemini.com (localhost [127.0.0.1]) by
mxiorb01.capgemini.com (8.13.3/8.12.11) with ESMTP id j38BNYYH012071
  for <J2EEPATTERNS-INTEREST@(protected)
      +0200 (MEST)
>Received: from ntbomexmta.corp.capgemini.com (ntbomexmta [10.48.144.55])
by       mxiorb01.capgemini.com (8.13.3/8.13.3) with ESMTP id
j38BNIvu011860       for <J2EEPATTERNS-INTEREST@(protected),
8 Apr 2005 13:23:33       +0200 (MEST)
>Received: from BOMEX001.corp.capgemini.com ([10.48.144.53]) by
ntbomexmta.corp.capgemini.com with Microsoft SMTPSVC(6.0.3790.211);
Fri, 8 Apr 2005 16:53:25 +0530
>X-Message-Info: nNbrIwMvXSSAJPzo4M4qM2xyKJV3NDtps+cNnG9EuGE=
>X-Original-To: J2EEPATTERNS-INTEREST@(protected)
>Delivered-To: J2EEPATTERNS-INTEREST@(protected)
>X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0
>Content-class: urn:content-classes:message
>X-MS-Has-Attach:
>X-MS-TNEF-Correlator:
>Thread-Topic: concurrency problem
>Thread-Index: AcU8LV+wY1ytqkN/SOyzTMyr9o8W7w==
>X-OriginalArrivalTime: 08 Apr 2005 11:23:25.0588 (UTC)
  FILETIME=[61706D40:01C53C2D]
>Precedence: list
>Return-Path: owner-j2eepatterns-interest@(protected)
>
>
>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)

====================================================================
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.