Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java Application gets permission denied error in Linux

  • 27-06-2012 2:38pm
    #1
    Registered Users, Registered Users 2 Posts: 19,050 ✭✭✭✭


    Hi all,
    I am having a little trouble understanding a problem.

    I have a java web app (actually an admin type app to administer a site) running locally on tomcat (under Eclipse).

    The admin app allows you to upload a graphic which is then saved on a server share (via a locally mounted directory).

    We all mount the server share locally and specify it in our build (maven settings.xml-not relevant to the problem anyway).

    When I attempt to upload a graphic using the app, I get a java exception:
    java.io.FileNotFoundException: /mnt/java/devstorage/content/category/icon/nav_photo.png (Permission denied)
    

    ...and I see the file name there where it should be BUT it's got zero bytes, it's empty, so it hasn't saved.

    /mnt/java/devstorage/content/category/icon/ is the local mount point-saving anything here means it is saved on the remote server so we can all see it in the team.

    If I start ecllipse as root, the thing works so it's a permissions problem for sure but if I (not as root) attempt to copy a file to /mnt/java/devstorage/content/category/icon/ then it also works.

    Has anybody got any ideas?


Comments

  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    chmod the directory. Also chown the pre-existing 0byte file if it's owned by root.


  • Registered Users, Registered Users 2 Posts: 19,050 ✭✭✭✭murphaph


    srsly78 wrote: »
    chmod the directory. Also chown the pre-existing 0byte file if it's owned by root.
    The destination directory /mnt/java/devstorage/content/category/icon/ is already 777 and the 0 byte file is owned by my own user, not root. Any other ideas?
    pmurphy@T420 /mnt/java/devstorage/content/category $ ls -l
    total 0
    drwxrwxrwx 2 1003 1003 0 2012-06-27 16:57 icon
    
    pmurphy@T420 ~/cat icons $ ls -l
    total 24
    -rw-rw-r-- 1 pmurphy pmurphy 414 2012-06-27 12:27 nav_home.png
    -rw-rw-r-- 1 pmurphy pmurphy 409 2012-06-27 12:27 nav_pc.png
    -rw-rw-r-- 1 pmurphy pmurphy 471 2012-06-27 12:27 nav_phone.png
    -rw-rw-r-- 1 pmurphy pmurphy 724 2012-06-27 12:27 nav_photo.png
    -rw-rw-r-- 1 pmurphy pmurphy 806 2012-06-27 12:27 nav_software.png
    -rw-rw-r-- 1 pmurphy pmurphy 295 2012-06-27 12:27 nav_tablet.png
    


  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    The files needs to have 777 as well if another user is trying to overwrite the file?


  • Registered Users, Registered Users 2 Posts: 19,050 ✭✭✭✭murphaph


    srsly78 wrote: »
    The files needs to have 777 as well if another user is trying to overwrite the file?
    I don't know how or why the files save like that (with those more restrictive permissions I mean).

    Even if I copy a file by hand using cp from the source to the destination folder, they end up with those same permissions (more restrictive than they originally had):
    rw-rw-r--
    
    becomes
    rw-r--r--
    

    Why would that be?


  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    Ugh I'm a bit rusty in this area... But I seem to remember there being some umask thing that defines the default permissions a new file gets.

    Some googling returns this, which may be helpful: http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

    You need to change the default umask for whichever user is creating those files.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 19,050 ✭✭✭✭murphaph


    srsly78 wrote: »
    Ugh I'm a bit rusty in this area... But I seem to remember there being some umask thing that defines the default permissions a new file gets.

    Some googling returns this, which may be helpful: http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

    You need to change the default umask for whichever user is creating those files.

    Thanks, that looks like it might be the right way to go!


  • Registered Users, Registered Users 2 Posts: 1,082 ✭✭✭Feathers


    murphaph wrote: »
    The destination directory /mnt/java/devstorage/content/category/icon/ is already 777 and the 0 byte file is owned by my own user, not root. Any other ideas?
    pmurphy@T420 /mnt/java/devstorage/content/category $ ls -l
    total 0
    drwxrwxrwx 2 1003 1003 0 2012-06-27 16:57 icon
    
    pmurphy@T420 ~/cat icons $ ls -l
    total 24
    -rw-rw-r-- 1 pmurphy pmurphy 414 2012-06-27 12:27 nav_home.png
    -rw-rw-r-- 1 pmurphy pmurphy 409 2012-06-27 12:27 nav_pc.png
    -rw-rw-r-- 1 pmurphy pmurphy 471 2012-06-27 12:27 nav_phone.png
    -rw-rw-r-- 1 pmurphy pmurphy 724 2012-06-27 12:27 nav_photo.png
    -rw-rw-r-- 1 pmurphy pmurphy 806 2012-06-27 12:27 nav_software.png
    -rw-rw-r-- 1 pmurphy pmurphy 295 2012-06-27 12:27 nav_tablet.png
    

    Who owns the tomcat instance? Is it you, or have you set up a tomcat user that you could give ownership of the file to?


Advertisement