[ 
https://issues.apache.org/jira/browse/OWB-1070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14535321#comment-14535321
 ] 

Mark Struberg commented on OWB-1070:
------------------------------------

I actually never did hit this problem in production until now. So I'm not quite 
sure if it is a problem in the real world or just caused by the TCK. It's about 
SessionContextAsyncListenerTest#testSessionContextActiveOnError. 
It first accesses the @SessionScoped bean in the AsyncListener#onError. 
I really need to think about the session handling in async servlets in general. 
In any case I cannot add any filter here as the WAR is not under my control.

Pleas note that TomEE did pass this test previously as we created the session a 
bit too eagerly. I 'fixed' this now and did hit this issue. 
PPS: In OWB-1.1 and 1.2 we also did lazy init of the session. But instead of 
storing the whole Conext Map in the Session we just did resolve the sessionId. 
But in the end it is exactly the same.

> eager session creation configuration
> ------------------------------------
>
>                 Key: OWB-1070
>                 URL: https://issues.apache.org/jira/browse/OWB-1070
>             Project: OpenWebBeans
>          Issue Type: New Feature
>          Components: Context and Scopes
>    Affects Versions: 1.5.0
>            Reporter: Mark Struberg
>            Assignee: Mark Struberg
>             Fix For: 1.6.0
>
>
> In OWB we try to not create any HttpSession if we do not need it. The reason 
> is that we do not like to pollute the Session for e.g. resource or JAXRS 
> requests. That would just blow up the memory.
> Instead we create the Session lazily. See 
> {{WebContextsService#lazyStartSessionContext(boolean createSession)}}.
> The ConversationContext and thus the Session gets started whenever you use a 
> @SessionScoped or @ConversationScoped bean the first time and there was no 
> Session yet. 
> If that is the case AFTER there was some HttpServletResponse written back to 
> the client. then you will get the following Exception:
> {quote}
> IllegalStateException: Cannot create a session after the response has been 
> committed.
> {quote}
> We might prevent this by starting the Session for every request. But this has 
> quite a few downsides, including slowing down any request and polluting 
> memory with useless Sessions.
> A possible solution would be to introduce an {{eagerSessionInitialisation}} 
> config entry via openwebbeans.properties. It could have 3 options
> * {{true}} will create a Session on each request start
> * {{false}} (should be default) will use lazySessionInit as always
> * a custom String which is a regexp for requests which need an eagerly 
> initialized Session. All other requests will use lazySessionInit.
> Any comment and further ideas are welcome.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to