You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Howard W. Smith, Jr. (JIRA)" <ji...@apache.org> on 2013/04/24 07:29:16 UTC

[jira] [Commented] (TOMEE-907) WARNING - Could NOT lazily initialize session context because of null RequestContext

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

Howard W. Smith, Jr. commented on TOMEE-907:
--------------------------------------------

I tried to send the following to tomee's user list 4 or 5 times, but mail delivery error every time, so I will add it here. :(

On Sun, Feb 3, 2013 at 12:55 PM, Jose Luis Cetina <ma...@gmail.com> wrote:

I test with a fresh snapshot of today, the warning still there, but my ear
now CAN run 2 webapps with sesionbeans with using login method
(request.login).

The warning now it just like it is JUST a Warning, but like Howard says how
can fix that warning, Rommain you told something about using a session
without a request, well my session only is hit it when the user is login
not before, thats why i dont understand exactly were can be hitted, maybe
you can take a look to the github project and take a look. 


Jose,

Are you still seeing this WARNING? Are you using latest version of TomEE 1.6.0 snapshot? I am still seeing this issue with 2013-03-27 version of TomEE 1.6.0 SNAPSHOT (haven't had a need to use the latest version, 2013-03-27 was my birthday...smile), and this version is after the date that Romain asked you/us to try the latest snapshot (which I assumed should have the fix for this issue).

>From what I am seeing in my log, this 'only' occurs for all user sessions that timeout via session timeout (as defined/specified in web.xml). The only code in my app that initiates an  HTTPSession is in my servlet filter.

It seems as though this WARNING is written to the log before/after each @SessionScoped bean is destroyed. To prove this, I am tempted to add @PreDestroy on all my @SessionScoped beans. Honestly, I started adding this to a few of my beans to help/promote GC (by setting bean attributes = null).

anyway, I think I will go ahead and make sure all my @SessionScoped beans have @PreDestroy and do a logger.info("COMPLETED") inside of @PreDestroy. this will be a proof of concept for me that it seems as though prior to destruction of @SessionScoped beans, TomEE is doing a getContext(), which attempts to lazily start session, if session/context == null. :(

Romain,

Okay, I finally found the problem (even though I'm looking at openejb 4.5.1, which is or maybe an older version). I just created the following JIRA; can you please make the code changes that I proposed/requested in that JIRA; i'm sure those code changes may meet the request of TomEE community (that includes myself and Jose, so far).

https://issues.apache.org/jira/browse/TOMEE-907
                
> WARNING - Could NOT lazily initialize session context because of null RequestContext
> ------------------------------------------------------------------------------------
>
>                 Key: TOMEE-907
>                 URL: https://issues.apache.org/jira/browse/TOMEE-907
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 1.6.0
>         Environment: N/A I'm using TomEE 1.6.0 snapshot 2013-03-27
>            Reporter: Howard W. Smith, Jr.
>            Priority: Minor
>              Labels: context, lazyStartSessionContext, session-context
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> 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;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira