JSF CDI ViewScoped Bean @PreDestroy在会话超时时抛出空指针异常

时间:2017-01-18 05:47:21

标签: cdi jsf-2.2 session-timeout view-scope

我有带@Named和@ViewScoped Annotation的CDI ViewScoped Bean。我定义了@PreConstruct和@PreDestroy函数。当我使用h:commandLink从My JSF页面导航到另一个页面时,我的@PreDestroy函数被调用,我的所有资源都被释放。但是如果会话超时,则此@PreDestroy函数调用将抛出NullPointerException。我甚至尝试在bean中使用空的@PreDestroy函数,但仍然会抛出Null指针Exception。 这可能是什么原因?

SEVERE: Exception thrown while destroying bean instance : [TestInfo, Name:testInfo, WebBeans Type:MANAGED, API Types:[java.io.Serializable,java.lang.Object,bean.TestInfo], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named]]
java.lang.NullPointerException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at  org.apache.webbeans.intercept.LifecycleInterceptorInvocationContext.proceed(LifecycleInterceptorInvocationContext.java:103)
    at org.apache.webbeans.portable.InjectionTargetImpl.preDestroy(InjectionTargetImpl.java:335)
    at org.apache.webbeans.component.AbstractOwbBean.destroy(AbstractOwbBean.java:180)
    at com.sun.faces.application.view.ViewScopeContextManager.destroyBeans(ViewScopeContextManager.java:145)
    at com.sun.faces.application.view.ViewScopeContextManager.sessionDestroyed(ViewScopeContextManager.java:275)
    at com.sun.faces.application.view.ViewScopeManager.sessionDestroyed(ViewScopeManager.java:345)
    at com.sun.faces.application.WebappLifecycleListener.sessionDestroyed(WebappLifecycleListener.java:177)
    at com.sun.faces.config.ConfigureListener.sessionDestroyed(ConfigureListener.java:368)
    at org.apache.catalina.session.StandardSession.expire(StandardSession.java:809)
    at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:657)
    at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:532)
    at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:517)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1352)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1546)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1556)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1556)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1524)
    at java.lang.Thread.run(Unknown Source)

0 个答案:

没有答案