  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | concurrency problem | concurrency problem 2005-04-08 - By Kalra, Ashwani
Back
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)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859 (See http://iso-8859.ora-code.com)-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD> <BODY> <DIV><FONT face=Arial size=2><FONT size=2> <P>I am facing concurrency problem in following scenario.</P> <P> </P> <P>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.</P> <P>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</P> <P> </P> <P>execute(...) //execute methods of Action class</P> <P>{</P> <P>....</P> <P>....</P> <P>//Obtain the session from Request.User will always be in session here</P> <P>session=request.getSession()</P> <P>Synchronised(session)</P> <P>{</P> <P>//call ejb's business method.</P> <P>}</P> <P> </P> <P>}</P> <P>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.</P> <P>Can there be problem in above code. Is it ok to synchronise on session
object.</P></FONT></FONT></DIV> <P><FONT face="Arial Narrow" size=2>Thanks & Regds</FONT><FONT face=Tahoma
size=2><BR><B></B></FONT><B></B><B><FONT
face="Arial Narrow"> Ashwani</FONT></B></P> <P><STRONG><FONT face="Arial Narrow">Ext: 1860</FONT></STRONG></P> <P><STRONG><FONT face="Arial Narrow"></FONT></STRONG><STRONG><FONT
face="Arial Narrow"></FONT></STRONG><STRONG><FONT
face="Arial Narrow"></FONT></STRONG><BR> </P> <DIV> </DIV></BODY></HTML>
<table><tr><td bgcolor=#ffffff><font color=#000000>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.<br> <br> </font></td></tr></table> ==================================================================== 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)
|
|
 |