使用PrimePush时出现NullPointerException



当我尝试初始化我的eventBus时,我得到了一个NullPointerException:

java.lang.NullPointerExceptionde.mrsfinster.web.livefeed.bean.FeedBean.init(FeedBean.java:179)位于的sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)位于的sun.reflect.NativeMethodAccessorImpl.invoke(未知源)位于的sun.reflect.DelegatingMethodAccessorImpl.invoke(未知源)位于的java.lang.reflect.Method.ioke(未知源)org.jboss.weld.interceptor.reser.SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(SimpleInterceptorInvocation.java:77)在org.jboss.weld.intercept.chain.AbstractInterceptionChain.invokeNext(AbstractInterceptionChain.java:126)在org.jboss.weld.intercept.chain.AbstractInterceptionChain.invokeNextInterceptor(AbstractInterceptionChain.java:102)在org.jboss.weld.intercept.proxy.InterceptorMethodHandler.executeInterception(InterceptorMethodHandler.java:43)在org.jboss.weld.intercept.proxy.InterceptorMethodHandler.invoke(InterceptorMethodHandler.java:28)在org.jboss.weld.bean.proxy.CombinedInterceptorAndDecoratorStackMethodHandler.invoke在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.BainjectionTarget.postConstruct(BeanjectionTarget.java:68)网址:org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:153)org.jboss.weld.util.bean.IsolatedForwardingBean.create(IsolatedForwarding bean.java:44)在org.jboss.weld.context.AbstractContext.get(AbstractContext.java:96)在org.jboss.weld.context.PassivatingContextWrapper$AbstractPassivatingContextWrapper.get(PassivatingContext Wrapper.java:76)在org.jboss.weld.manager.BeanManageImpl.getReference(BeanManageImpl.java:742)在org.jboss.weld.AbstractWeldELResolver.lockup(AbstractweldELResolve.java:107)在org.jboss.weld.AbstractWeldELResolver.getValue(AbstractweldELResolve.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(DemuxComposite ELResolver.java:176)在com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxComposite ELResolver.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.ioke(AstValue.java:275)com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)在org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethod Expression.java:40)在org.jboss.weld.WeldMethodExpression.invoke(WeldMethod Expression.java:50)在org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethod Expression.java:40)在org.jboss.weld.WeldMethodExpression.invoke(WeldMethod Expression.java:50)在com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)在com.sun.faces.facelets.tag.jsf.core.DelativeSystemEventListener.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(RenderResonsePhase.java:107)在com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)com.sun.faces.lifecycle.Impl.render(LifecycleImpl.java:219)位于javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)io.bundertow.servlet.handlers.servlet处理程序.handleRequest(servlet处理程序.java:85)在io.bundertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)在io.bundertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDisptchingHandler.java:36)在org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)在io.bundertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在io.bundertow.servlet.handlers.security.SSLInformation AssociationHandler.handleRequest(SSLInformation AssociationHandler.java:131)在io.bundertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(servlet AuthenticationCallHandler.java:56)在io.bundertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在io.bundertow.security.handlers.AbstractConfidentityHandler.handleRequest(AbstractConfidentiityHandler.java:45)在io.bundertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(servlet Confidentiality ConstraintHandler.java:63)在io.bunderstream.security.handlers.AuthenticationMechanismHandler.handleRequest(AuthenticationMechinismHandler.java:58)在io.bundertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticated SessionHandler.java:70)在io.bundertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)在io.bundertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在org.wildfly.extension.undertow.security.jacc.JACContextIdHandler.handleRequest(JACContentIdHandler.java:61)在io.bundertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在io.bundertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)在io.bundertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261)在io.bundertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247)在io.bundertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76)在io.bundertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166)在io.bunderstream.server.Connectors.executeRootHandler(Connectors.java:197)在io.bunderstream.server.HttpServerExchange$1.run(HttpServerExchange.java:759)位于java.util.concurrent.ThreadPoolExecutor.runWorker(未知源)位于java.util.concurrent.ThreadPoolExecutor$Worker.run(未知源)在java.lang.Thread.run(未知源)

这是我的代码:

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

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

我的web.xml配置:

<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以进行正确初始化:

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

只需将下面的代码放入默认的构造函数

"eventBus = EventBusFactory.getDefault().eventBus();"

它适用于任何版本。

相关内容

  • 没有找到相关文章

最新更新