jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Klimetschek" <aklim...@day.com>
Subject Re: Threads in jackrabbit application
Date Thu, 13 Nov 2008 12:33:54 GMT
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 <rajn@softwaremind.pl> 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

Mime
View raw message