You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Karl Kildén (JIRA)" <ji...@apache.org> on 2016/03/02 17:17:18 UTC

[jira] [Commented] (OWB-1124) Lazy start on SessionContext NPE on no active RequestContext

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

Karl Kildén commented on OWB-1124:
----------------------------------

Workaround:

For me it is just a matter of try catching the call to ContextUtils and treat the error as false

> Lazy start on SessionContext NPE on no active RequestContext
> ------------------------------------------------------------
>
>                 Key: OWB-1124
>                 URL: https://issues.apache.org/jira/browse/OWB-1124
>             Project: OpenWebBeans
>          Issue Type: Bug
>         Environment: TomEE 7.0M1
>            Reporter: Karl Kildén
>            Assignee: Karl Kildén
>
> I upgraded to TomEE 7-M1 and I have a problem with checking for active contexts. Now this behavior:
>         ServletRequestContext requestContext = getRequestContext(true);
>         if (requestContext == null)
>         {
>             logger.log(Level.WARNING, "Could NOT lazily initialize session context because NO active request context");
>         }
> Only logs it and goes ahead and breaks on NPE on line 815 but before it simply never executed any code if requestContext was null. 
> This is the code in my application that actually uses Deltaspike now for checking:
> 	private boolean isActive(Class<? extends Annotation> scope) {
> 		return ContextUtils.isContextActive(scope);
> 	}
> Full stacktrace
>             at org.apache.webbeans.web.context.WebContextsService.lazyStartSessionContext(WebContextsService.java:815)
>             at org.apache.webbeans.web.context.WebContextsService.getSessionContext(WebContextsService.java:739)
>             at org.apache.webbeans.web.context.WebContextsService.getCurrentContext(WebContextsService.java:277)
>             at org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:287)
>             at org.apache.webbeans.container.InjectableBeanManager.getContext(InjectableBeanManager.java:129)
>             at org.apache.deltaspike.core.util.ContextUtils.isContextActive(ContextUtils.java:60)
>             at org.apache.deltaspike.core.util.ContextUtils.isContextActive(ContextUtils.java:46)
>             at com.company.ContextLookup.isActive(ContextLookup.java:23)
> My actual use case is that I tag all my entities if I can find out who changed it but in this case it was a background thread.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)