Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-907

WARNING - Could NOT lazily initialize session context because of null RequestContext

    XMLWordPrintableJSON

Details

    Description

      To prevent this from showing in the log 'always', when/during/after session expiration, please see my code changes below. Look for 'PLEASE MODIFY BELOW, accordingly:' below. Thanks.

      private Context lazyStartSessionContext() {

      if (logger.isDebugEnabled())

      { logger.debug(">lazyStartSessionContext"); }

      Context webContext = null;
      Context context = getCurrentContext(RequestScoped.class);
      if (context instanceof ServletRequestContext) {
      ServletRequestContext requestContext = (ServletRequestContext) context;
      HttpServletRequest servletRequest = requestContext.getServletRequest();
      if (null != servletRequest) { // this could be null if there is no active request context
      try {
      HttpSession currentSession = servletRequest.getSession();
      initSessionContext(currentSession);
      // if (failoverService != null && failoverService.isSupportFailOver())
      //

      { // failoverService.sessionIsInUse(currentSession); // }

      if (logger.isDebugEnabled())

      { logger.debug("Lazy SESSION context initialization SUCCESS"); }

      } catch (Exception e)

      { logger.error(OWBLogConst.ERROR_0013, e); }

      } else {

      PLEASE MODIFY BELOW, accordingly:

      • if (logger.isDebugEnabled()) { * logger.warning("Could NOT lazily initialize session context because NO active request context"); * }

      }
      } else {

      PLEASE MODIFY BELOW, accordingly:

      • if (logger.isDebugEnabled()) { * logger.warning("Could NOT lazily initialize session context because of " + context + " RequestContext"); * }

      }

      if (logger.isDebugEnabled())

      { logger.debug("<lazyStartSessionContext " + webContext); }

      return webContext;
      }

      Attachments

        1. LoginFilter.java
          10 kB
          Howard W. Smith, Jr.

        Activity

          People

            Unassigned Unassigned
            smithh032772 Howard W. Smith, Jr.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified