请选择 进入手机版 | 继续访问电脑版
本站特色:极好的技术研究氛围!所有技术发帖,必有回复! 做最受欢迎的Java论坛

疯狂Java联盟

 找回密码
 加入联盟
查看: 168|回复: 3

[轻量级Java EE] 第8章第7节光盘上的2个代码运行时出现错误

[复制链接]
发表于 2018-2-24 19:05:27 | 显示全部楼层 |阅读模式
第一个例子 spring-manage-action 第二个例子 autowire 都出现了如下的运行错误。

Struts Problem Report
Struts has detected an unhandled exception:
Messages:
File:org/crazyit/app/service/impl/MyServiceImpl.java
Line number:19


Stacktracesjava.lang.NullPointerException    org.crazyit.app.service.impl.MyServiceImpl.validLogin(MyServiceImpl.java:19)    org.crazyit.app.action.LoginAction.execute(LoginAction.java:52)    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    java.lang.reflect.Method.invoke(Method.java:498)    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)    org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:254)    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2521)    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2510)    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)    java.lang.Thread.run(Thread.java:745)   



You are seeing this page because development mode is enabled. Development mode, or devMode, enables extra debugging behaviors and reports to assist developers. To disable this mode, set:
  struts.devMode=falsein your WEB-INF/classes/struts.properties file.


发表于 2018-2-25 13:40:46 | 显示全部楼层
看上去像你的DAO组件没有注入Service组件,检查你是否配置了DAO组件注入Service组件。
 楼主| 发表于 2018-2-25 16:05:12 | 显示全部楼层
本帖最后由 wkylpy 于 2018-2-25 16:09 编辑

我上传一下我的源码吧!依赖的包文件太大,分2个附件上传。

spring-manage-action.rar

9.35 KB, 下载次数: 10

lib1.rar

3.99 MB, 下载次数: 8

lib2.rar

5.44 MB, 下载次数: 8

发表于 2018-2-26 12:59:24 | 显示全部楼层
先用光盘的代码测,
然后对比你的代码和光盘代码的差异。
您需要登录后才可以回帖 登录 | 加入联盟

本版积分规则

小黑屋|手机版|Archiver|疯狂Java联盟 ( 粤ICP备11063141号 )

GMT+8, 2018-6-26 03:25 , Processed in 0.258699 second(s), 7 queries , File On.

快速回复 返回顶部 返回列表