Java Mailing List Archive

http://www.junlu.com/

Google
Google
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
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
concurrency problem

concurrency problem

2005-04-08       - By Kalra, Ashwani

 Back
Reply:     1     2     3     4     5     6     7     8  


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>&nbsp;</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>&nbsp;</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>&nbsp;</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 &amp; Regds</FONT><FONT face=Tahoma

size=2><BR><B></B></FONT><B></B><B><FONT

face="Arial Narrow">&nbsp;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>&nbsp;</P>
<DIV>&nbsp;</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)

©2008 junlu.com - Jax Systems, LLC, U.S.A.