使用 PrimePush 时出现 NullPointerException [英] NullPointerException when using PrimePush

查看:37
本文介绍了使用 PrimePush 时出现 NullPointerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试初始化我的 eventBus 时,我收到 NullPointerException:

When I try to initialize my eventBus I'm getting a NullPointerException:

java.lang.NullPointerException 在de.mrsfinster.web.livefeed.bean.FeedBean.init(FeedBean.java:179) 在sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) atsun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) atjava.lang.reflect.Method.invoke(Unknown Source) atorg.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:77)在org.jboss.weld.interceptor.chain.AbstractInterceptionChain.invokeNext(AbstractInterceptionChain.java:126)在org.jboss.weld.interceptor.chain.AbstractInterceptionChain.invokeNextInterceptor(AbstractInterceptionChain.java:102)在org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:43)在org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:28)在org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:53)在de.mrsfinster.web.livefeed.bean.FeedBean$Proxy$_$$_WeldSubclass.lifecycle_mixin_$$_postConstruct(未知来源)在org.jboss.weld.interceptor.util.InterceptionUtils.executePostConstruct(InterceptionUtils.java:38)在org.jboss.weld.interceptor.util.InterceptionUtils.executePostConstruct(InterceptionUtils.java:50)在org.jboss.weld.injection.producer.BeanInjectionTarget.postConstruct(BeanInjectionTarget.java:68)在 org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:153) 在org.jboss.weld.util.bean.IsolatedForwardingBean.create(IsolatedForwardingBean.java:44)在org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)在org.jboss.weld.context.PassivatingContextWrapper$AbstractPassivatingContextWrapper.get(PassivatingContextWrapper.java:76)在org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:742)在org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)在org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90)在org.jboss.as.jsf.injection.weld.ForwardingELResolver.getValue(ForwardingELResolver.java:46)在javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188)在com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)在com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)在 com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)在 com.sun.el.parser.AstValue.getBase(AstValue.java:151) 在com.sun.el.parser.AstValue.getTarget(AstValue.java:170) 在com.sun.el.parser.AstValue.invoke(AstValue.java:275) 在com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)在org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)在org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)在org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)在org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)在com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)在com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128)在javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2584)在javax.faces.event.SystemEvent.processListener(SystemEvent.java:108)在javax.faces.event.ComponentSystemEvent.processListener(ComponentSystemEvent.java:118)在com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2190)在com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2135)在com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:289)在com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:247)在org.jboss.as.jsf.injection.weld.ForwardingApplication.publishEvent(ForwardingApplication.java:299)在com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)在 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 在com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)在 javax.faces.webapp.FacesServlet.service(FacesServlet.java:647) 在io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)在io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)在io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)在org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)在io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)在io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63)在io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)在io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)在io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)在io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247)在io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76)在io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166)在io.undertow.server.Connectors.executeRootHandler(Connectors.java:197)在io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759)在 java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)在 java.util.concurrent.ThreadPoolExecutor$Worker.run(未知来源)在 java.lang.Thread.run(Unknown Source)

java.lang.NullPointerException at de.mrsfinster.web.livefeed.bean.FeedBean.init(FeedBean.java:179) 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.jboss.weld.interceptor.reader.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:77) at org.jboss.weld.interceptor.chain.AbstractInterceptionChain.invokeNext(AbstractInterceptionChain.java:126) at org.jboss.weld.interceptor.chain.AbstractInterceptionChain.invokeNextInterceptor(AbstractInterceptionChain.java:102) at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:43) at org.jboss.weld.interceptor.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:28) at org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke(CombinedInterceptorAndDecoratorStackMethodHandler.java:53) at de.mrsfinster.web.livefeed.bean.FeedBean$Proxy$_$$_WeldSubclass.lifecycle_mixin_$$_postConstruct(Unknown Source) at org.jboss.weld.interceptor.util.InterceptionUtils.executePostConstruct(InterceptionUtils.java:38) at org.jboss.weld.interceptor.util.InterceptionUtils.executePostConstruct(InterceptionUtils.java:50) at org.jboss.weld.injection.producer.BeanInjectionTarget.postConstruct(BeanInjectionTarget.java:68) at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:153) at org.jboss.weld.util.bean.IsolatedForwardingBean.create(IsolatedForwardingBean.java:44) at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96) at org.jboss.weld.context.PassivatingContextWrapper$AbstractPassivatingContextWrapper.get(PassivatingContextWrapper.java:76) at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:742) at org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107) at org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:90) at org.jboss.as.jsf.injection.weld.ForwardingELResolver.getValue(ForwardingELResolver.java:46) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188) at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116) at com.sun.el.parser.AstValue.getBase(AstValue.java:151) at com.sun.el.parser.AstValue.getTarget(AstValue.java:170) at com.sun.el.parser.AstValue.invoke(AstValue.java:275) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128) at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2584) at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108) at javax.faces.event.ComponentSystemEvent.processListener(ComponentSystemEvent.java:118) at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2190) at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2135) at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:289) at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:247) at org.jboss.as.jsf.injection.weld.ForwardingApplication.publishEvent(ForwardingApplication.java:299) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

这是我的代码:

@PostConstruct
public void init() {
    eventBus = EventBusFactory.getDefault().eventBus();
}

我使用的是 Primefaces 5.2、Wildfly 8.2.0.final、大气运行时 2.4.0-RC3.

I'm using Primefaces 5.2, Wildfly 8.2.0.final, atmosphere-runtime 2.4.0-RC3.

我的 web.xml 配置:

My web.xml configuration:

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

推荐答案

显然 EventBusFactory.getDefault() 返回 null.在将 PrimeFaces 升级到 5.2 并讨论后可能会出现此问题,例如,此处.尝试在启动时加载 PushServlet 以进行正确的初始化:

Apparently EventBusFactory.getDefault() returns null. This problem may appear after upgrading the PrimeFaces to 5.2 and discussed, for example, here. Try to load the PushServlet on startup for proper initialization:

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

这篇关于使用 PrimePush 时出现 NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆