Return-Path: Delivered-To: apmail-jackrabbit-users-archive@locus.apache.org Received: (qmail 99610 invoked from network); 13 Nov 2008 14:25:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Nov 2008 14:25:04 -0000 Received: (qmail 19315 invoked by uid 500); 13 Nov 2008 14:25:10 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 19296 invoked by uid 500); 13 Nov 2008 14:25:10 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 19285 invoked by uid 99); 13 Nov 2008 14:25:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Nov 2008 06:25:10 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of aklimets@day.com designates 207.126.148.182 as permitted sender) Received: from [207.126.148.182] (HELO eu3sys201aog002.obsmtp.com) (207.126.148.182) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 13 Nov 2008 14:23:50 +0000 Received: from source ([209.85.198.247]) by eu3sys201aob002.postini.com ([207.126.154.11]) with SMTP ID DSNKSRw4n363Tj5fsiL070KxRZr2Jki6wVGD@postini.com; Thu, 13 Nov 2008 14:24:34 UTC Received: by rv-out-0708.google.com with SMTP id f25so872545rvb.14 for ; Thu, 13 Nov 2008 06:24:31 -0800 (PST) Received: by 10.140.125.1 with SMTP id x1mr5478740rvc.265.1226579634150; Thu, 13 Nov 2008 04:33:54 -0800 (PST) Received: by 10.140.144.3 with HTTP; Thu, 13 Nov 2008 04:33:54 -0800 (PST) Message-ID: Date: Thu, 13 Nov 2008 13:33:54 +0100 From: "Alexander Klimetschek" To: users@jackrabbit.apache.org Subject: Re: Threads in jackrabbit application In-Reply-To: <491C1D58.8070807@softwaremind.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <491C1D58.8070807@softwaremind.pl> X-Virus-Checked: Checked by ClamAV on apache.org Hi Rafael, Sessions in JCR are not thread-safe, so each user/request should have its own session (Sessions are designed to be retrieved and released quickly, unlike a jdbc connection). If all your threads use the same session, this might be the reason for the (somewhat unexpected) ConstraintViolationException. To avoid conflicts, you can solve that by using a good content model or for example using open-scoped locking. You might also design your application to handle conflicts, ie. keep the content that could not be saved and offer a conflict resolution to the user (eg. "was already modified, here is the difference / do you want to overwrite / etc."). Regards, Alex On Thu, Nov 13, 2008 at 1:28 PM, RafalJanik wrote: > Hi > I'm testing JackRabbit and i'm wondering how it will be work when many users > in the same time start adding the nodes and uploading the files. So I make > few threads - each one gets reference to Session. > When task is done there is a line (Session) session.save() but if in another > thread e.g. uploading is in progress there is an Exception > (javax.jcr.nodetype.ConstraintViolationException:) - i think it is caused by > saving action in first thread which wants to save session in the thread with > uploading and not all mandatory fields have been written yet... Is it > correct? > And how can I run adding or uploading nodes on two or more threads? Is > method join() only a reason? > What i should do to make my application with JackRabbit enable for many > users to edit in the same time ? > > Cheers > > Rafael > -- Alexander Klimetschek alexander.klimetschek@day.com