JFinal上传NullPointerException错误

D-L 发布于 2014/06/30 10:21
阅读 863
收藏 0

使用JFinal上传的一个操作,在本地测试没有问题,上传到服务器后报空指针。

本地环境:Tomcat7

服务器环境使用的是Apache+JK+Tomcat8

2014-06-30 10:15:37
[ERROR]-[Thread: ajp-apr-127.0.0.1-8009-exec-5]-[com.jfinal.core.ActionHandler.handle()]: /sunsystem/savebanner
java.lang.NullPointerException
        at com.jfinal.upload.MultipartRequest.handleSaveDirectory(MultipartRequest.java:78)
        at com.jfinal.upload.MultipartRequest.wrapMultipartRequest(MultipartRequest.java:88)
        at com.jfinal.upload.MultipartRequest.<init>(MultipartRequest.java:59)
        at com.jfinal.core.Controller.getFiles(Controller.java:655)
        at com.sunarvr.admin.AdminController.savebanner(AdminController.java:219)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55)
        at com.jfinal.plugin.ehcache.EvictInterceptor.intercept(EvictInterceptor.java:28)
        at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51)
        at com.sunarvr.admin.AdminInterceptor.intercept(AdminInterceptor.java:20)
        at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51)
        at com.jfinal.core.ActionHandler.handle(ActionHandler.java:73)
        at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:78)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
        at org.apache.coyote.ajp.AbstractAjpProcessor.process(AbstractAjpProcessor.java:794)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2451)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2440)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)NullPointerExceptionNullPointerException

加载中
0
JFinal
JFinal
saveDirectory 这个参数不能是 null ,改下实参为非 null 打完收工
0
D-L
D-L

saveDirectory 已经设置了,在本地没任何问题,放到服务器就报错了。@JFinal

0
JFinal
JFinal

引用来自“D-L”的评论

saveDirectory 已经设置了,在本地没任何问题,放到服务器就报错了。@JFinal

服务器上获取到的 strPath 为 null,可能是 getRealPath(...) 这句的行为 linux 上与 windows 上有所不同,换成 getRealPath("/upload/artres/"); 试试
mi-la-king
mi-la-king
要么用 File.separator 试试
JFinal
JFinal
回复 @D-L : 都是 windows 机器,那就有可能是其它问题了,例如服务器是否为 tomcat而本地开发用的 jetty
D-L
D-L
确实是这个问题,在本机是Windows 8 环境,服务器是Windows Server 2008。难道这两个Windows处理还不一样?
0
D-L
D-L
@JFinal 感谢回答。
0
木川瓦兹
木川瓦兹
空指针有可能没把cos包导进去
返回顶部
顶部