You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Irek Matysiewicz <ir...@poczta.fm> on 2006/10/26 15:24:15 UTC

MyFaces and multithreading problem

We have a managed bean with session scope. It's used in one .jsp file. Usually only one thread uses this bean, and everything works ok. But today we discovered, that two threads access the same getter method of the bean at the same time, and this leads to serious problems. Both getter invocations come from MyFaces. Of course the simplest method is to use 'synchronized' attribute with all methods visible to MyFaces, but this may slow down our application.

Why does MyFaces use two threads here? Is there a better method than synchronized? Maybe some setting in a configuration file?


----------------------------------------------------------------------
Jestes kierowca? To poczytaj! >>> http://link.interia.pl/f199e


Re: MyFaces and multithreading problem

Posted by dm...@xbiosystem.com.
I'm not entirely sure about the threading model that MyFaces uses, however
I have noticed that callbacks from the extention filter may be on
different threads.

Daniel

> By definition, one request is only processed by one execution thread. I
> don't thins myfaces starts a new thread in order to do things (but in
> fact,
> I cannot confirm it). What I've found some times is a double submit issue
> (of course nothing to do with myfaces).
>
> Check that you are not submit the same form two times.
>
> Ricardo.
>
>
> On 26 Oct 2006 15:24:15 +0200, Irek Matysiewicz <ir...@poczta.fm> wrote:
>>
>> We have a managed bean with session scope. It's used in one .jsp file.
>> Usually only one thread uses this bean, and everything works ok. But
>> today
>> we discovered, that two threads access the same getter method of the
>> bean at
>> the same time, and this leads to serious problems. Both getter
>> invocations
>> come from MyFaces. Of course the simplest method is to use
>> 'synchronized'
>> attribute with all methods visible to MyFaces, but this may slow down
>> our
>> application.
>>
>> Why does MyFaces use two threads here? Is there a better method than
>> synchronized? Maybe some setting in a configuration file?
>>
>>
>> ----------------------------------------------------------------------
>> Jestes kierowca? To poczytaj! >>> http://link.interia.pl/f199e
>>
>>
>



Re: MyFaces and multithreading problem

Posted by Ricardo Tercero Lozano <rt...@gmail.com>.
By definition, one request is only processed by one execution thread. I
don't thins myfaces starts a new thread in order to do things (but in fact,
I cannot confirm it). What I've found some times is a double submit issue
(of course nothing to do with myfaces).

Check that you are not submit the same form two times.

Ricardo.


On 26 Oct 2006 15:24:15 +0200, Irek Matysiewicz <ir...@poczta.fm> wrote:
>
> We have a managed bean with session scope. It's used in one .jsp file.
> Usually only one thread uses this bean, and everything works ok. But today
> we discovered, that two threads access the same getter method of the bean at
> the same time, and this leads to serious problems. Both getter invocations
> come from MyFaces. Of course the simplest method is to use 'synchronized'
> attribute with all methods visible to MyFaces, but this may slow down our
> application.
>
> Why does MyFaces use two threads here? Is there a better method than
> synchronized? Maybe some setting in a configuration file?
>
>
> ----------------------------------------------------------------------
> Jestes kierowca? To poczytaj! >>> http://link.interia.pl/f199e
>
>