本文介绍了使用PrimePush时发生NullPointerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试初始化eventBus时,出现NullPointerException:
When I try to initialize my eventBus I'm getting a NullPointerException:
这是我的代码:
@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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!