我在代码中遇到"NullPointerException"
。我们已经检查过非空,但它在下面的屏幕截图中不适用于我们。我已经检查了folderInfoData.getSelectedInfoRole() != null
但是输入了if语句。这是private SelectOption<String> selectedInfoRole;
类型。
如何解决此问题?
18:26:22,589 246302 ERROR [zk.ui.impl.UiEngineImpl ] -
java.lang.NullPointerException
at com.csdcsystems.amanda.web.viewmodel.FolderProcessInfoViewModel.saveInfoDetails(FolderProcessInfoViewModel.java:234)
at com.csdcsystems.amanda.web.viewmodel.FolderProcessInfoViewModel.saveProcessInfo(FolderProcessInfoViewModel.java:201)
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.zkoss.bind.impl.ParamCall.call(ParamCall.java:113)
at org.zkoss.bind.impl.BinderImpl.doExecute(BinderImpl.java:1748)
at org.zkoss.bind.impl.BinderImpl.doCommand(BinderImpl.java:1509)
at org.zkoss.bind.impl.BinderImpl.access$1500(BinderImpl.java:108)
at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent0(BinderImpl.java:1378)
at org.zkoss.bind.impl.BinderImpl$CommandEventListener.onEvent(BinderImpl.java:1330)
at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:2746)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2717)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:2658)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:136)
at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1765)
at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1550)
at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1260)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:603)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:485)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:494)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.csdcsystems.servlets.AmandaSessionFilter.doFilter(AmandaSessionFilter.java:46)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
18:26:22,597 246302 INFO [csdcsystems.amanda.web.AmandaPerformanceMeter ] - Command name:saveProcessInfo
这是截图:
答案 0 :(得分:4)
我的猜测是你有一个NullPointerException,因为folderInfoData.getFolderprocessInforecord()
或folderInfoData.getSelectedInfoRole().getValue()
返回null,然后你就调用getInfoValue
。
为了帮助调试类似的问题,请尝试简化线条:
infoRole = folderInfoData.getSelectedoInfoRole().getValue();
infoRecord = folderInfoData.getFolderprocessInforecord().getValue();
if (!infoRole.equals(infoRecord) {
...
}
这将在第二行报告NullPointerException,并且可以节省一些时间进行调试。