Spring Struts Hibernate Trouble Shooting | A record of some problems

Source: Internet
Author: User

Struts 2 Struts 2 upload file error

[16:09:13,321 catalina-exec-5] Commonslogger.warn (56) | Could not find create multipart save directory '/attachment '.
[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 (without that file or directory)

...

caused by:java.io.filenotfoundexception:attachment/upload__58686996_15b664f6902__8000_00000005.tmp (without that file or directory)
At Java.io.FileOutputStream.open (Native Method)

...

Root Cause:

Struts-main.xml specify where to save the uploaded file:

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

Then the attachment folder will be created in the User.dir location, User.dir for the Tomcat startup.sh to start the working directory, generally tomcat/bin directory;

However, if the current directory at/xxx/tomcat/bin/startup.sh startup is the root directory/, and the Tomcat startup user does not have permission to create a directory in the/directory, uploading the file will fail with an error as above.

Solution:

1. Switch the working directory when Tomcat starts

2. Make sure that the attachment directory can be created in any directory launched by Tomcat

Reference:

Notes on Struts.multipart.saveDir not set or set: http://mossad.iteye.com/blog/1522905

Spring Struts Hibernate Trouble Shooting | A record of some problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.