[ https://issues.apache.org/jira/browse/OWB-1070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14537090#comment-14537090 ]
Mark Struberg commented on OWB-1070: ------------------------------------ It is a real issue but one does hardly hit it. And no, it's not TomEE related but affects OWB on pure Tomcat as well. > 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)