[jboss-jira] [JBoss JIRA] (WFLY-10281) NPE when initializing CDI bean during startup that injects PushContext
Martin Kouba (JIRA)
issues at jboss.org
Mon Apr 23 03:24:00 EDT 2018
[ https://issues.jboss.org/browse/WFLY-10281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13565019#comment-13565019 ]
Martin Kouba commented on WFLY-10281:
-------------------------------------
Reassigning as the NPE comes from {{com.sun.faces.cdi.CdiUtils#isScopeActive()}} so I believe this is primarily a JSF problem.
> NPE when initializing CDI bean during startup that injects PushContext
> ----------------------------------------------------------------------
>
> Key: WFLY-10281
> URL: https://issues.jboss.org/browse/WFLY-10281
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, JSF
> Affects Versions: 12.0.0.Final
> Reporter: Rich DiCroce
> Assignee: Martin Kouba
>
> If a CDI bean injects PushContext (for JSF websocket support, new in JSF 2.3) and is instantiated during startup, a NullPointerException occurs.
> The offending method is part of Mojarra. Looking at the code, I'm guessing FacesContext is null since JSF has not initialized yet, and apparently the BeanManager has not been bound in JNDI yet either. It doesn't try CDI.current() at all, though I have no idea if that would help.
> I'm currently working around this by injecting Instance<PushContext> instead.
> {code}
> 2018-04-20 11:48:39,577 ERROR [com.sgi.song.gpnms.timer.ExecutorTimerService] (EE-ManagedExecutorService-default-Thread-2) Exception invoking timer com.sg.song.nms.endpoint.sbc.SmartBinOverviewBean performRefresh: java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_162]
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_162]
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_162]
> at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_162]
> at com.sgi.song.gpnms.timer.ExecutorTimerService.lambda$0(ExecutorTimerService.java:72) [gp-ispn-shared-2.0.0-SNAPSHOT.jar:]
> at com.sgi.song.gpnms.timer.ExecutorTimerService.lambda$2(ExecutorTimerService.java:199) [gp-ispn-shared-2.0.0-SNAPSHOT.jar:]
> at org.jboss.as.ee.concurrent.ControlPointUtils$ControlledRunnable.run(ControlPointUtils.java:105) [wildfly-ee-12.0.0.Final.jar:12.0.0.Final]
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_162]
> at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_162]
> at org.glassfish.enterprise.concurrent.internal.ManagedFutureTask.run(ManagedFutureTask.java:141) [javax.enterprise.concurrent-1.0.jar:]
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_162]
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_162]
> at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_162]
> at org.glassfish.enterprise.concurrent.ManagedThreadFactoryImpl$ManagedThread.run(ManagedThreadFactoryImpl.java:250) [javax.enterprise.concurrent-1.0.jar:]
> at org.jboss.as.ee.concurrent.service.ElytronManagedThreadFactory$ElytronManagedThread.run(ElytronManagedThreadFactory.java:78)
> Caused by: org.jboss.weld.exceptions.WeldException: WELD-000049: Unable to invoke void com.sg.song.nms.endpoint.sbc.SmartBinOverviewBean.init() on com.sg.song.nms.endpoint.sbc.SmartBinOverviewBean at 7afeacb8
> at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:85) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.postConstruct(DefaultLifecycleCallbackInvoker.java:66) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.producer.BasicInjectionTarget.postConstruct(BasicInjectionTarget.java:122) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:172) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy.get(ContextualInstanceStrategy.java:140) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:102) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at com.sg.song.nms.endpoint.sbc.SmartBinOverviewBean$Proxy$_$$_WeldClientProxy.performRefresh(Unknown Source) [classes:]
> ... 15 more
> Caused by: java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_162]
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_162]
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_162]
> at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_162]
> at org.jboss.weld.injection.producer.DefaultLifecycleCallbackInvoker.invokeMethods(DefaultLifecycleCallbackInvoker.java:83) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> ... 25 more
> Caused by: java.lang.NullPointerException
> at com.sun.faces.cdi.CdiUtils.isScopeActive(CdiUtils.java:378) [jsf-impl-2.3.3.SP1.jar:2.3.3.SP1]
> at com.sun.faces.push.WebsocketPushContext.<init>(WebsocketPushContext.java:95) [jsf-impl-2.3.3.SP1.jar:2.3.3.SP1]
> at com.sun.faces.cdi.WebsocketPushContextProducer.produce(WebsocketPushContextProducer.java:86) [jsf-impl-2.3.3.SP1.jar:2.3.3.SP1]
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_162]
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_162]
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_162]
> at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_162]
> at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.producer.ProducerMethodProducer.produce(ProducerMethodProducer.java:103) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.producer.AbstractMemberProducer.produce(AbstractMemberProducer.java:161) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:180) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:70) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:689) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:789) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:335) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:346) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:69) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:71) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:159) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ContextualInstanceStrategy$ApplicationScopedContextualInstanceStrategy.get(ContextualInstanceStrategy.java:140) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:102) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:131) [weld-core-impl-3.0.3.Final.jar:3.0.3.Final]
> at com.sg.song.nms.network.command.CommandSender$Proxy$_$$_WeldClientProxy.registerSender(Unknown Source) [classes:]
> at com.sg.song.nms.endpoint.sbc.SmartBinOverviewBean.init(SmartBinOverviewBean.java:86) [classes:]
> ... 30 more
> {code}
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
More information about the jboss-jira
mailing list