LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-03-2012, 11:22 AM   #1
javaman
LQ Newbie
 
Registered: Aug 2012
Location: Nashville, TN
Posts: 4

Rep: Reputation: Disabled
Unhappy Trying to write a file (text), but getting (permission denied)


I have a Java label printing app deployed on JBoss 7 on a Linux OS server. The app formats / writes a text file with user keyed data and then sends the file to a printer. On my workstation, using the same version of JBoss 7, this works every time. On the Linux server, I get "java.io.filenotfoundexception filename.txt (permission denied)" every time. This continues despite the fact that I changed the folder permissions to 777. At this point, I'm not even sure whether it's JBoss or Linux that won't let the app create this file, but I've been checking forums, googling the error message, and reading user guides without finding any answers, so far.

Last edited by javaman; 08-03-2012 at 11:33 AM.
 
Old 08-03-2012, 12:20 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Are you sure the file is being created in the directory that you think it's going in? Do you see the full path to the file in the exception? Do you have access to the source to dump out the file name with the full path before it attempts to write it?
 
Old 08-06-2012, 08:22 AM   #3
javaman
LQ Newbie
 
Registered: Aug 2012
Location: Nashville, TN
Posts: 4

Original Poster
Rep: Reputation: Disabled
It is on my PC. What I see in the exception is exactly the path I specified in my code. I also have a log message, but it shows the same thing as the exception.
 
Old 08-06-2012, 08:28 AM   #4
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
But does the path which will contain the file exist on the server? Which user is currently running the JBoss instance on the server?
 
Old 08-06-2012, 09:05 AM   #5
javaman
LQ Newbie
 
Registered: Aug 2012
Location: Nashville, TN
Posts: 4

Original Poster
Rep: Reputation: Disabled
If I specify no path (just filename), on my PC the file gets written to the JBoss bin folder; but on the server I still get (permission denied). Since both places have the same version installed (7.1.1), I would expect the same result. I've also tried several "relative" paths (like "../standalone/tmp/", which absolutely does exist in JBoss 7). On my PC, this works and the file is written to the specified location, but no joy on the Linux server. Does Linux compute paths differently from Windows?
 
Old 08-06-2012, 09:28 AM   #6
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
What user is JBoss running as?

Do you have the source for this webapp?
 
Old 08-06-2012, 09:41 AM   #7
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
Here's the most likely issue you're encountering: JBoss has been probably installed by an admin user on the server machine, but the user which launched it hasn't got the same permission as the one who installed it, so there's no way any application launched from it can alter the JBoss installation contents. This is perfectly normal behavior, as server software is often launched as an unprivileged user to minimize some intrusion risks.
Given that the text file seems to be only a temporary file, you should exploit the File.createTempFile(..) method of the File class to let the Java VM choose a "safe" path where you can write temporary files and the like.

Last edited by 414N; 08-07-2012 at 08:31 AM. Reason: removed a type
 
Old 08-07-2012, 08:28 AM   #8
javaman
LQ Newbie
 
Registered: Aug 2012
Location: Nashville, TN
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thumbs up Trying to write text file permission problem solved

I'm happy to report a solution to this issue. Apparently, Linux resolves "relative" addressing in a different way than Windows. Following a suggestion from a co-worker, the app now retrieves a JBoss system property and sets an "absolute" filepath using that value plus the filename.
Many thanks for your time and attention.
Sincerely, javaman
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp permission denied but have write access linuxfia Linux - Software 5 08-14-2008 12:33 PM
open for write: permission denied zechdc Linux - Server 2 01-02-2008 07:13 AM
Cannot write to /misc directory - permission denied as root etuhs Fedora 4 06-01-2007 08:20 AM
Permission Denied for script accessing text file lobo1 Linux - General 2 06-28-2005 01:46 PM
Permission denied when trying to write to ttyS0 thepoint Linux - General 0 06-03-2004 10:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration