struts2 报错:java.lang.NullPointerException: Source must not be null

今天使用strut2+ajax进行异步上传时出错,控制台没有打印信息,ajax回调函数中alert返回值得到如下信息,大概就是空指针的意思。

实际上是上传的input name值和action变量名不一致造成。input name为myfile,变量为myFile,一个字母的大小写造成的错误!注意这个地方!

HTTP Status 500 -



type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException: Source must not be null 
    org.apache.commons.io.FileUtils.copyFile(FileUtils.java:761) 
    org.apache.commons.io.FileUtils.copyFile(FileUtils.java:731) 
    com.etoak.action.UploadAction.execute(UploadAction.java:44) 
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    java.lang.reflect.Method.invoke(Method.java:606) 
    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.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:239) 
    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:239) 
    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:325) 
    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:161) 
    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:563) 
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) 
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) 

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.6 logs.


Apache Tomcat/7.0.6

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-15 18:42:07

struts2 报错:java.lang.NullPointerException: Source must not be null的相关文章

Java Web项目报错java.lang.NullPointerException at org.apache.jsp.front.index_jsp._jspInit(index_jsp.java:30)

环境:myeclipse+tomcat6+jdk6 今天搭建了一个Java Web项目,访问index.jsp时报如下错误: 严重: Servlet.service() for servlet jsp threw exceptionjava.lang.NullPointerException    at org.apache.jsp.front.index_jsp._jspInit(index_jsp.java:30)    at org.apache.jasper.runtime.HttpJs

项目报错java.lang.ClassNotFoundException: org.common.SessionListener

现象:项目报错java.lang.ClassNotFoundException: org.common.SessionListener,并且myeclipse左侧Package Explorer中项目目录的WEB-INF下显示多了个classes文件夹.既然报错是ClassNotFoundException,就去tomcat的WEB-INF/classes下找该项目,的确没有class文件. 解决方法:右击项目,点击properties(或者右击项目,选择build path--config b

maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener

本篇文章主要介绍了"maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener ",主要涉及到maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener 方面的内容,对于maven web 项目中启动报错jav

报错:java.lang.Long cannot be cast to java.lang.Integer

Long 无法转化成Integer类型. 这个异常 经常出现在hinbernate分页查询的时候. 原因: 这里在Hibernate2.0之前版本list.get(0)返回的是Integer类型. 但是在Hibernate3.0以后版本list.get(0)返回的是Long类型. 解决方法 public Integer getUsersCount() { String hql = "select count(*) from Users"; List list = super.pageQ

开着idea,死机了,关机重启。重启之后,重新打开idea报错java.lang.AssertionError:upexpected content storage modification

开着idea,死机了,关机重启.重启之后,重新打开idea报错java.lang.AssertionError:upexpected content storage modification. goole得到: If you cannot even open your project in IntelliJ: Close IntelliJ Go to the directory <your_home>/.IntelliJIdeaXX/system/cache where XX is your

eclipse下执行wordcount报错 java.lang.ClassNotFoundException 解决办法

eclipse下执行wordcount报错 java.lang.ClassNotFoundException 17/08/29 07:52:54 INFO Configuration.deprecation: fs.default.name is deprecated. Instead, use fs.defaultFS 17/08/29 07:52:54 WARN util.NativeCodeLoader: Unable to load native-hadoop library for y

Android Studo 使用 JNI报错:java.lang.UnsatisfiedLinkError: Couldn&#39;t load XXX from loader dalvik.system.PathClassLoader

今天在使用Android Studio的时候突然发现代码没错,so包也引入了,各个版本都引入了,但是就是一直报错: java.lang.UnsatisfiedLinkError: Couldn't load serphone from loader dalvik.system.PathClassLoader 11-30 11:13:18.766 29255-29255/com.personal.tai.ronglianim E/AndroidRuntime: at java.lang.Runti

MyEclipse2014报错java.lang.ClassNotFoundException

MyEclipse2014做web开发的时候,总是报错java.lang.ClassNotFoundException.而对应的类有能在包中找到.原因一般是由下面情况引起的. 在开发的时候,我们习惯性的在lib下面根据包类型或作用分文件夹来管理,然后手动将包导入到项目中(此时包会在Referenced Libraries中),而MyEclipse2014只会自动加载Web app Libraries文件夹中的包. 解决办法就是,将所有的支撑包都放到lib目录下,而不要在lib目录下分文件夹管理.

jdbc连接sqlserver报错java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

使用2008的数据库, 我已经引入的sqljdbc4的包,单还是报这个错,很奇怪突然想到在配置hibernate的时候,是拷贝下来的代码 然后到网上查了下, 因为是2008的版本驱动和2000的有点不同, 之前的都是可能是2000或者2005的class是com.microsoft.jdbc.sqlserver.SQLServerDriver 可是2008  去是com.microsoft.sqlserver.jdbc.SQLServerDriver 就这么改过来就可以了 jdbc连接sqlse