Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-1070

eager session creation configuration

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.6.0
    • Component/s: Context and Scopes
    • Labels:
      None

      Description

      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:

      IllegalStateException: Cannot create a session after the response has been committed.

      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.

        Attachments

          Activity

            People

            • Assignee:
              struberg Mark Struberg
              Reporter:
              struberg Mark Struberg
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: