Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 59485 invoked from network); 16 Apr 2005 20:19:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Apr 2005 20:19:40 -0000 Received: (qmail 26644 invoked by uid 500); 16 Apr 2005 20:19:38 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 26580 invoked by uid 500); 16 Apr 2005 20:19:38 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 26567 invoked by uid 99); 16 Apr 2005 20:19:38 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from khefrksrv013.khecorp.com (HELO khefrksrv013.KHECORP.COM) (205.204.234.76) by apache.org (qpsmtpd/0.28) with ESMTP; Sat, 16 Apr 2005 13:19:37 -0700 Received: by khefrksrv013.khecorp.com with Internet Mail Service (5.5.2653.19) id <27MARDWW>; Sat, 16 Apr 2005 16:20:14 -0400 Message-ID: From: "Kumar, Kiran" To: 'Torsten Curdt' , "'dev@cocoon.apache.org'" Subject: RE: Problem with sharing sessions/ multithreading Date: Sat, 16 Apr 2005 16:20:10 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi this is a problem I am working on. and I need to fix this ASAP. we have a website with thousands of users logging in to check their account information. we are using Cocoon 2.1 version. we also tried no-cache on all the stylesheets. It did not work and according to the Web-Team this is taking longer time to load the pages with lots of images. we had synchronized the code which creates the xml DOM objects using here is the action templates we use ---------------------------------------------------------------------- this is the first action which creates the documents. ++++++++++++++++++++++++++++++++++ public class XmlAction extends AbstractAction implements SingleThreaded { /** * @see org.apache.cocoon.acting.Action#act(Redirector, SourceResolver, Map, String, Parameters) */ public Map act(Redirector redirector,SourceResolver resolver,Map objectModel ,String source,Parameters parm) throws Exception { Map map = new HashMap(); Request request = ObjectModelHelper.getRequest(objectModel); Session session = request.getSession(true); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); synchronized(dbf) { doc = dbf.newDocumentBuilder().newDocument(); } session.setAttribute("myAttribute", doc); session.setAttribute("root", sroot); return map; } } ------------------------------------------------------------------------ other actions use this session document to append/remove the elements +++++++++++++++++++++++++ public class OtherAction extends AbstractAction implements ThreadSafe { /** * @see org.apache.cocoon.acting.Action#act(Redirector, SourceResolver, Map, String, Parameters) */ public Map act(Redirector redirector,SourceResolver resolver,Map objectModel ,String source,Parameters parm) throws Exception { Map map = new HashMap(); Request request = ObjectModelHelper.getRequest(objectModel); Session session = request.getSession(true); doc = (Document)session.getAttribute("myAttribute"); ---- ---- ---- session.setAttribute("myAttribute", doc); session.setAttribute("root", sroot); return map; } } ------- All the actions follow the same structure > this session related issue. > > Here is an overview of what exactly happening. > > We developed web applications using Apache Cocoon framework. After user > authenticates ( against custom registry database), > > I create a DOM object for the user with his account information and store > in > session. (I use cocoon SessionAttributeGenerator to transform the DOM to > a > HTML using XSL). > > Here the dom objects are being shared between sessions and I am seeing > data > from other users or processes. > > I used the synchronized blocks when creating xml doms from > DocumentBuilderFactory newBuilder().newDocument() etc but it didnt fix > the > issue > > is there any way I can resolve this issue?? > > I found in the cocoon users group that by using the Java Filters with > cocoon > servlet fixed this problem? > > could you give me some examples about how to use the filters effectively > > appreciate your response. Also I can give more information required. > > > thanks Kiran -----Original Message----- From: Torsten Curdt [mailto:tcurdt@apache.org] Sent: Saturday, April 16, 2005 4:09 PM To: dev@cocoon.apache.org Subject: Re: Problem with sharing sessions/ multithreading Kumar, Kiran wrote: > Hi all > > this is a problem I am working on. and I need to fix this ASAP. > > we have a website with thousands of users logging in to check their account > information. > > we are using Cocoon 2.1 version. we > > also tried no-cache on all the stylesheets. It did not work and according to > the Web-Team this is taking longer time to load the pages with lots of > images. > > we had synchronized the code which creates the xml DOM objects using > > here is the action templates we use Kiran, please elaborate a bit more on the problem you are facing. BTW: > DocumentBuilderFactory dbf = > DocumentBuilderFactory.newInstance(); Since you create a new instance of the DBF there is no need for the synchronization. Only the access to the DBF is not guarantied to be threadsafe AFAIK. > synchronized(dbf) { > doc = dbf.newDocumentBuilder().newDocument(); > } cheers -- Torsten