I guess you could safely share your IStringResourceLoaders, as they
are already shared
between multiple session (and thus potentially multiple threads).
If you really need to share the Session object between threads, you have
to roll some kind of locking. What I've done in the past is adding a
ReentrantLock
to the session, which every thread has to acquire before using the session.
For web request threads, this can be done in WebRequestCycle.
However, I would advise against sharing the whole session, but just to
share what's actually needed and guard the access to that.

cheers,
Jonas

On Wed, Feb 10, 2010 at 12:08 PM, Matthias Keller
<matthias.kel...@ergon.ch> wrote:
> Hi
>
> We have a complex application which needs to calculate some very expensive
> things. Those could easily be parallelized so we thought about having a
> thread pool to do that.
> Unfortunately, that code needs access to the localizer and the application
> (for some configuration values) so we're setting the Session and the
> Application explicitly in that thread using  Application.set() and
>  Session.set().
> But this always leads to a strange error - I suspect it has something to do
> with the 'duplicated' session or application?
>
> Any hints about how to do this correctly? Do we need to do something special
> with the session or application at the end of the thread?
>
> Thanks!
>
> Matt
>
>
> Here's the stacktrace:
>
> WicketMessage: Method onFormSubmitted of interface
> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component
> [MarkupContainer [Component id = SignupForm]] threw an exception
>
> Root cause:
>
> ExceptionConverter: java.io.IOException: No message found for
> the.document.has.no.pages
>
> Complete stack:
>
> org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of
> interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at
> component [MarkupContainer [Component id = SignupForm]] threw an exception
> at
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:194)
> at
> org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
> at
> org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
> at
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1175)
> at org.apache.wicket.RequestCycle.step(RequestCycle.java:1252)
> at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1353)
> at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
> at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:355)
>
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:183)
> at
> org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
> at
> org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
> at
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1175)
> at org.apache.wicket.RequestCycle.step(RequestCycle.java:1252)
> at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1353)
> at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
> at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:355)
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to