空指针是什么回事?

来源:4-3 配置Action,Service,Dao的类-Struts2整合Spring

慕尼黑9146956

2017-05-23 17:12

Action中的save方法执行了。。。。

ERROR [http-bio-8088-exec-4] - Exception occurred during processing request: null

java.lang.NullPointerException

at cn.muke.ssh.action.ProductAction.save(ProductAction.java:44)

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 ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:870)

at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1293)

at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)

at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:117)

at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:108)

at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1369)

at ognl.ASTMethod.getValueBody(ASTMethod.java:90)

at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)

at ognl.SimpleNode.getValue(SimpleNode.java:258)

at ognl.Ognl.getValue(Ognl.java:494)

at ognl.Ognl.getValue(Ognl.java:458)

at com.opensymphony.xwork2.ognl.OgnlUtil$2.execute(OgnlUtil.java:309)

at com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecute(OgnlUtil.java:340)

at com.opensymphony.xwork2.ognl.OgnlUtil.getValue(OgnlUtil.java:307)

at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:423)

at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:287)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:250)

at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)

at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)

at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76)

at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)

at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)

at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at org.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:125)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)

at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)

at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)

at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)

at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)

at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)

at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)

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:318)

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)

五月 23, 2017 5:08:01 下午 org.apache.catalina.core.StandardContext reload

信息: Reloading Context with name [/ssh] has started

五月 23, 2017 5:08:01 下午 org.apache.catalina.core.ApplicationContext log

信息: Closing Spring root WebApplicationContext

五月 23, 2017 5:08:03 下午 org.apache.catalina.startup.TldConfig execute

信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

五月 23, 2017 5:08:03 下午 org.apache.catalina.core.ApplicationContext log

信息: No Spring WebApplicationInitializer types detected on classpath

五月 23, 2017 5:08:03 下午 org.apache.catalina.core.ApplicationContext log

信息: Initializing Spring root WebApplicationContext

五月 23, 2017 5:08:05 下午 org.apache.catalina.core.StandardContext reload

信息: Reloading Context with name [/ssh] is completed


写回答 关注

2回答

  • 您的昵称已被使用
    2017-07-04 12:14:13

    ProductAction类里面的私有对象productService和application.xml配置里面的productService的ID的配置不一致导致的空指针错误

    IT小白丶4...

    谢谢,已解决,没注意到名称不一样,还想着是怎么传递的对象...

    2018-08-25 14:49:12

    共 1 条回复 >

  • 慕粉4315839
    2017-05-24 16:01:50

    你这没代码没法看呀

基于SSH实现员工管理系统之框架整合篇

本视频教程主要介绍环境搭建和SSH框架整合,逐层深入理解学习

49832 学习 · 344 问题

查看课程

相似问题