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

Joe Bergmark commented on OWB-1070:
-----------------------------------

I agree this is a tricky problem to solve.

The crux of the issue is that once the headers have been sent it is too late to 
try and create the session.  The headers could have been sent because something 
did an explicit flush, or because enough data has been written that whatever 
internal buffers the servlet container decides to start writing to the client.

In general the only way to avoid this is to decide if you need a session for a 
particular request before you start writing any significant amount of data, or 
keep trying to increase whatever settings allow you to tweak the buffer sizes 
of the servlet container to delay the decision as long as you can (assuming no 
explicit flush is called)

> 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