tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Curwen" <gb_...@gb-im.com>
Subject RE: writing to File-System; IOException on File.mkdirs() and/or File.createNewFile()
Date Wed, 28 Apr 2004 13:40:23 GMT
Do you have the same problem if you make the directory 766 or 776 ?

> -----Original Message-----
> From: Christoph Meier [mailto:christoph.meier@webmover.ch] 
> Sent: Tuesday, April 27, 2004 5:53 PM
> To: tomcat-user@jakarta.apache.org
> Subject: writing to File-System; IOException on File.mkdirs() 
> and/or File.createNewFile()
> 
> 
> Hallo
> 
> i have some problems writing Files to the local harddisk.
> running Tomcat 5.19 on a Linux with a jre1.4.2, Tomcat 
> started without 
> security-option;
> process-owner is a user called "tomcat5"
> 
> i'm trying to write a File (from scratch)  into 
> $catalinaBase/webapps/myApp/  .
> $catalinaBase/**  belongs to user tomcat5, Permissions set to 770  .
> 
> i'm doing something like:
> --------------------------------------------------------------
> -----------
>         File aFile = new File(aFilePath);
>         if (!aFile.mkdirs()){
>           //
>         }
>        
>         if (aFile.exists()){
>             if (!aFile.delete()){
>              //
>             }
>         }
>         try {
>             aFile.createNewFile();
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>           // adding some xml into the file ...
>          addContentToFile(aFile);
> ------------------------------------------------------------
> if the parent directory of "aFilePath" already exists, 
> everything works 
> fine ...
> if  one of the parent-dirs is missing, it fails ...
> e.g. $catalinaBase/webapps/myApp/myTestFile.txt  wil be 
> created (since 
> $catalinaBase/webapps/myApp already exists), but
> $catalinaBase/webapps/myApp/a/b/c/myTestFile.txt  fails  ....
> 
> when debugging i see that  >>aFile.mkdirs()<< returns false ... but 
> since it throws no Exception, i has no clear idea why mkdirs() fails,
> later in the code >>aFile.createNewFile()<< throws an IOException ...
>  >>
> java.io.IOException: /home/hmb/catalina_5_19/webapps/hmb/a/1.txt
>         at java.io.UnixFileSystem.createFileExclusively(Native Method)
>         at java.io.File.createNewFile(File.java:828)
>         at ch.hmb.app.service.TestService.writeTo(TestService.java:93)
> <<
> when inspecting the IOException with debugger (using Eclipse 
> build 30M8) 
> root-cause of IOException or its localized message only contains the 
> path of the File which i wanted to create ... (e.g. 
> /home/hmb/catalina_5_19/webapps/hmb/a/1.txt)
> 
> the "funny" thing is, all works fine with same Deployment on 
> win2000 and 
> solaris (with same permissions set, i guess).
> 
> has somebody an idea? does the problem concern 
> rights/permissions and/or 
> user/groups on the file-system or must i do a special grant in the 
> cataliny.policy (and starting tomcat with the security option)?
> 
> thanks in advance,
> kind regards
> christoph
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message