3

I have CDI ViewScoped Bean with @Named and @ViewScoped Annotation. I have @PreConstruct and @PreDestroy functions defined. When I navigate from My JSF page to another page using h:commandLink, my @PreDestroy function gets called and all my resources gets freed up. But if the session times out, this @PreDestroy function call throws NullPointerException. I even tried having empty @PreDestroy function in the bean, but still it throws Null pointer Exception. What could be the possible reason this?

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)
  • 1
    Can you share your code? We need to see the `@PreDestroy` method which raisesd the NPE. – Rouliboy Jan 18 '17 at 09:48
  • Did u find the reason, Facing the same with CDI producer bean, while destroying entity manager bean, Following is my stack trace ProducerMethodBean destroy Exception thrown while destroying bean instance : [-1411059665,Name:null,WebBeans Type:PRODUCERMETHOD,API Types:[java.lang.Object,javax.persistence.EntityManager],Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]] Cause : NPE – BalaajiChander Dec 06 '17 at 05:06
  • Getting the same in TomEE plume 7.04 – Panu Haaramo Jan 15 '18 at 17:23
  • Getting a lot of these in TomEE plume 7.10 Docker. – Panu Haaramo Mar 28 '20 at 10:04

0 Answers0