wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Tomcat Permissions - java.io.FileNotFoundException Permission denied Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat Permissions - java.io.FileNotFoundException Permission denied" Watch "Tomcat Permissions - java.io.FileNotFoundException Permission denied" New topic
Author

Tomcat Permissions - java.io.FileNotFoundException Permission denied

jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
I've got a problem writing a pdf file to a folder. Part of my work already has PHP reading and writing to this folder. The folders read/write permissions are set correctly

But i can't write to it with my jsp application.

I understand there are SecurityManager Permission classes applicable to Tomcat such as: java.io.FilePermission each controls read/write/execute access to files and directories.

In tomcat 5.5 - i have a catalina.policy file, but i don't know how to grant permission to read/write to that folder

I added this to the catalina.policy file under _ web application permissions _ , but it doesn't work.






ERROR
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

jite eghagha wrote:I've got a problem writing a pdf file to a folder. Part of my work already has PHP reading and writing to this folder. The folders read/write permissions are set correctly

But i can't write to it with my jsp application.


Then that suggests to me that the two applications might be running under different user profiles. Check out whether your so-called "correct" permissions work the same for both profiles.
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
Yes, they are both in two different profiles - the PHP doesn't run in Tomcat. The jsp is running on Tomcat 5.5 i installed on the Godaddy VPS.

I can read files in the folder.


causes this error......java.io.FileNotFoundException: /home/admin/public_html/sandbox/server/applicantForms/164287384763216/GENLABOUT.pdf (Permission denied)



Maxim Karvonen
Ranch Hand

Joined: Jun 14, 2013
Posts: 101
    
  10
It's not a JVM-level permission, it's an OS-level permission. You cannot fix with problem with SecurityManager configuration. You should modify OS-level permissions for that directory or run both applications using same system account. Just for test calling "chmod +w <directory>" should fix the problem (you may also need to set write permission on individual files). Note that "read permission" and "write perimission" are not a same permission. So it is possible that some account can read directory but can't write into it.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15956
    
  19

Typically, an Apache (PHP) web server will run under one userID, such as "apache" and the Tomcat web server will run under a userID of its own, such as "tomcat".

In order for both users to be able to write, both userids would have to be in a write-enabled protection group for that particular directory.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat Permissions - java.io.FileNotFoundException Permission denied
 
Similar Threads
Getting permission denied error on file upload
My JSP Syntax is correct but still getting 500 error code
request.setAttribute() and request.getAttribute()
I can not write in file
Suddenly stopped working