• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat Permissions - java.io.FileNotFoundException Permission denied

 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21117
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic