Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java Application gets permission denied error in Linux

  • 27-06-2012 03:38PM
    #1
    Registered Users, Registered Users 2 Posts: 19,117 ✭✭✭✭


    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,117 ✭✭✭✭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,117 ✭✭✭✭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,117 ✭✭✭✭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