惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
V
Visual Studio Blog
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
B
Blog
I
InfoQ
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
H
Help Net Security
博客园 - Franky
宝玉的分享
宝玉的分享
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家

博客园 - Mark Jiao

调试Java程序持续占cpu问题 Freemarker notes | Freemarker学习笔记 MySQL 性能调优之查询优化 Tomcat性能调优 | Tomcat Performance Tuning Tomcat配置、管理和问题解决 | Tomcat Configuration, Manangement and Trouble Shooting SWT Browser & XULRunner Windows应用安装制作工具调查报告 CentOS Configuration | CentOS配置 命令行加载IE ActiveX插件 Java那些事儿 互联网技术要考虑的事情 Parameterized Testing | 参数化测试 Git usage | Git 使用 Introduce products I worked on | 介绍一下我做过的产品 PHPUnit manual note | PHPUnit手册笔记 PHP manual notes | PHP手册笔记 Globalization, Localization, Internationalization and Translation HTTP 超文本传输协议 Design Patter
Spring Struts Hibernate trouble shooting | 一些问题的记载
Mark Jiao · 2017-04-13 · via 博客园 - Mark Jiao

Struts 2

Struts 2上传文件报错

[13 16:09:13,321 catalina-exec-5] CommonsLogger.warn(56) | Could not find create multipart save directory '/attachment'.
[13 16:09:13,323 catalina-exec-5] CommonsLogger.warn(60) | Unable to parse request
org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. attachment/upload__58686996_15b664f6902__8000_00000005.tmp (没有那个文件或目录)

...

Caused by: java.io.FileNotFoundException: attachment/upload__58686996_15b664f6902__8000_00000005.tmp (没有那个文件或目录)
    at java.io.FileOutputStream.open(Native Method)

...

Root cause:

struts-main.xml指定上传文件的保存位置:

<constant name="struts.multipart.saveDir" value="attachment" />

那么attachment文件夹会创建在user.dir位置下,user.dir为tomcat startup.sh执行时启动的工作目录,一般为tomcat/bin目录;

但如果/xxx/tomcat/bin/startup.sh启动时的当前目录为根目录/,而tomcat启动用户并没有在/目录创建目录的权限,上传文件就会失败,并报错如上。

Solution:

1. 切换tomcat启动时的工作目录

2. 在tomcat启动的任何目录确保可以创建attachment目录

Reference:

关于struts.multipart.saveDir不设置或设置的说明:http://mossad.iteye.com/blog/1522905