提问者:小点点

java. lang.NullPointerException在org.primeface.model.chart.BarChartModel.getTicks


我正在使用Tomcat7,当我运行我的服务器时,我得到了这个错误。我没有得到这个错误,它工作得很好,但是突然出现了这个错误。网页显示,只有当我在页面中提交表单时,这个错误才会出现。

java.lang.NullPointerException
    at org.primefaces.model.chart.BarChartModel.getTicks(BarChartModel.java:82)
    at org.primefaces.component.chart.renderer.BarRenderer.encodeOptions(BarRenderer.java:81)
    at org.primefaces.component.chart.renderer.BasePlotRenderer.render(BasePlotRenderer.java:30)
    at org.primefaces.component.chart.ChartRenderer.encodeScript(ChartRenderer.java:98)
    at org.primefaces.component.chart.ChartRenderer.encodeEnd(ChartRenderer.java:67)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:924)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
    at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:282)
    at org.richfaces.renderkit.html.TogglePanelItemRenderer.doEncodeChildren(TogglePanelItemRenderer.java:140)
    at org.richfaces.renderkit.html.TabRenderer.doEncodeChildren(TabRenderer.java:113)
    at org.richfaces.renderkit.RendererBase.encodeChildren(RendererBase.java:158)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
    at org.richfaces.renderkit.RendererBase.renderChildren(RendererBase.java:282)
    at org.richfaces.renderkit.html.TogglePanelRenderer.doEncodeChildren(TogglePanelRenderer.java:129)
    at org.richfaces.renderkit.RendererBase.encodeChildren(RendererBase.java:158)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
    at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:114)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    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 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

共2个答案

匿名用户

调试错误后,我发现我使用了BarChartModel的一个变量,但不小心删除了我设置它的行。

匿名用户

java. lang.NullPointerException at org.primeface.model.chart.BarChartModel.getTicks(BarChartModel.java:82

因为在你的BarChartModel中:-

如果您使用Map并像这样设置键/值:

map. set(键,值);

因此,键不能为空。