• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Java Issues-Permissions Denied-Plesk12.0

SamirM

Regular Pleskian
Hi,
i run a VPS with CentOS 7.1 and Plesk 12.0.18 and tomcat 7.0, am having issues with permissions even though all permissions have been enabled. The site runs a page for sellers to add their profile and product images, and when they upload the images, the following error is reported:

type Exception report

message java.io.FileNotFoundException: /var/www/vhosts/domain.com/httpdocs/uploads (Permission denied)

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

exception

java.io.IOException: java.io.FileNotFoundException: /var/www/vhosts/perkmart.com/httpdocs/uploads (Permission denied)
Upload.doPost(Upload.java:47)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause

java.io.FileNotFoundException: /var/www/vhosts/domain.com/httpdocs/uploads (Permission denied)
java.io.FileOutputStream.open(Native Method)
java.io.FileOutputStream.<init>(FileOutputStream.java:221)
java.io.FileOutputStream.<init>(FileOutputStream.java:171)
org.apache.tomcat.util.http.fileupload.disk.DiskFileItem.write(DiskFileItem.java:377)
Upload.doPost(Upload.java:47)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

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


the uploads folder has the following permissions : rwx-rwx-rw
the java code for the uploads is :

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;

@WebServlet("/upload")
@MultipartConfig(fileSizeThreshold = 1024 * 1024 * 2, // 2MB
maxFileSize = 1024 * 1024 * 10, // 10MB
maxRequestSize = 1024 * 1024 * 50) // 50MB
public class Upload extends HttpServlet {

/**
* Name of the directory where uploaded files will be saved, relative to the
* web application directory.
*/
private static final String SAVE_DIR = "domain.com/uploads/buyer_profile_photos/";

/**
* handles file upload
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// gets absolute path of the web application
// constructs path of the directory to save uploaded file

File fileSaveDir = new File(SAVE_DIR);
if (!fileSaveDir.exists()) {
fileSaveDir.mkdir();
}

for (Part part : request.getParts()) {
String fileName = extractFileName(part);
part.write(savePath + File.separator + fileName);
}
PrintWriter printWriter = response.getWriter();
printWriter.print(request.getServletContext().getRealPath(""));

}

/**
* Extracts file name from HTTP header content-disposition
*/
private String extractFileName(Part part) {
String contentDisp = part.getHeader("content-disposition");
String[] items = contentDisp.split(";");
for (String s : items) {
if (s.trim().startsWith("filename")) {
return s.substring(s.indexOf("=") + 2, s.length() - 1);
}
}
return "";
}
}


can anyone help in identifying the cause of this error

thanks\
samir
 
Thnx UFHH01, i have enabled "777" permissions to the folder, but i still get the same error.....any suggestions
 
i got this one sorted, apparently it was a SELINUX issue which was enabled, made it permissive and it started working, thnx UFHH01
 
Back
Top