Doug

finally, it works.

This appears to be a permissions issue. ...

you are right.
you might remember that i started Tomcat with a custom-script (see some post before)
ps -auxfw =>
#--------------------
root 9267 0.0 0.0 28 28 ? S Apr17 0:02 runsv tomcat
root 29989 0.0 0.0 1416 564 ? S 16:26 0:00 \_ jsvc.exec -XX:NewSize=48m -XX:MaxNewSize=48m -XX:SurvivorRatio=8
tomcat5 29992 6.9 3.3 708184 68556 ? S 16:26 0:03 \_ jsvc.exec -XX:NewSize=48m -XX:MaxNewSize=48m -XX:SurvivorRati
tomcat5 29993 0.0 3.3 708184 68556 ? S 16:26 0:00 \_ jsvc.exec -XX:NewSize=48m -XX:MaxNewSize=48m -XX:Survivor
tomcat5 29994 0.3 3.3 708184 68556 ? S 16:26 0:00 \_ jsvc.exec -XX:NewSize=48m -XX:MaxNewSize=48m -XX:Surv
tomcat5 29995 0.0 3.3 708184 68556 ? S 16:26 0:00 \_ jsvc.exec -XX:NewSize=48m -XX:MaxNewSize=48m -XX:Surv
tomcat5 29996 0.0 3.3 708184 68556 ? S 16:26 0:00 \_ jsvc.exec -XX:NewSize=48m -XX:MaxNewSize=4
#--------------------
the process on top still belongs root (which i did not expected) , but this is just an observation,
is still do not understand its effect



after your mail i tried using the "normal" catalina.sh start =>
#-----------------------------------------------
tomcat5 30290 70.0 2.3 696512 48568 pts/4 R 16:29 0:02 /usr/java/bin/java -Dlog4j.configuration=file:////home/hmb/catalina_5
tomcat5 30291 0.0 2.3 696512 48572 pts/4 S 16:29 0:00 \_ /usr/java/bin/java -Dlog4j.configuration=file:////home/hmb/catali
tomcat5 30292 0.0 2.3 696512 48572 pts/4 S 16:29 0:00 \_ /usr/java/bin/java -Dlog4j.configuration=file:////home/hmb/ca
tomcat5 30293 0.0 2.3 696512 48572 pts/4 S 16:29 0:00 \_ /usr/java/bin/java -Dlog4j.configuration=file:////home/hmb/ca
tomcat5 30294 0.0 2.3 696512 48572 pts/4 S 16:29
#--------------------


now even the Tomcat-"top"-process belomgs to tomcat5 and everything works.

actually it was "our" admin who advised to use the runsv-daemon to controll the tomcat-process ... its job is to restart the process if Tomcat-top-process should go down ... actually a practically thing ... but well

It may be the file system does not like the mkdirs() command for non root
users.


such behaviour i would considerate as a bug.
i'm extremly happy this is not the case.


Thanks for your hints!


_christoph

Another test would be to logon as tomcat5 and run your program from the
shell. If it fails, that backs up the idea that you need to be root to run
mkdirs(). Or that you still don't have the correct permissions set.

Do a ls -l on your directories and drill down several levels to ensure that
the change propagated down.

Next look at the directories and see if the command mkdirs() created any of
the levels.

Also what are the permissions set for on the catalina_5_19 directory?

I am no expert on this by far and it is possible that I am missing
something.

As another test, I you would like, email me directly your test file and I
will run it on my test box. I am also running TC5 on Linux and JDK1.4.2.

Doug


----- Original Message ----- From: "Christoph Meier" <[EMAIL PROTECTED]>
To: "Parsons Technical Services" <[EMAIL PROTECTED]>
Sent: Saturday, May 01, 2004 7:02 AM
Subject: Re: writing to File-System; IOException on File.mkdirs() and/or
File.createNewFile()





Doug

thanks for your hint.
when running tomcat as root, now it works (i thought that i already
tried that out, obvisouly i didn't)
 ...  the TestService worked suddenly, other parts of my cms-app i had
to "fix" a bit; it seems like there some file operations which work on
solaris with a jdk1.3 but do not not with the jdk1.4.2 on linux; but i
adapted it now

.... BUT
... after doing
# chown -Rc tomcat5 /home/hmb/catalina_5_19
and
# chgrp -Rc tomcat5 /home/hmb/catalina_5_19

and starting tomcat as tomcat5...
... i have the same problems like before



java.io.IOException:



/home/hmb/catalina_5_19/webapps/hmb/cms-content/edit/contents/xml/pages/de.x
ml


java.io.IOException:



/home/hmb/catalina_5_19/webapps/hmb/cms-content/edit/contents/xml/pages/de.x
ml


at java.io.UnixFileSystem.createFileExclusively(Native Method) at
java.io.File.createNewFile(File.java:828) at
ch.webmover.cms.content.page.XmlCmsPage.save
<<<<<<<<<<

... whereas the root-cause for the failing of  >>createNewFile()<< still
is the failing of mkdirs() like describedin my last post ...

anyway, Doug, thank you.

_christoph



Christoph,

Just as a quick test try this.

Start Tomcat from the prompt as root using
/home/hmb/catalina_5_19/bin/startup.sh

If it works you have a permissions problem.

# chown -Rc tomcat5 /home/hmb/catalina_5_19

and for good measure

# chgrp -Rc tomcat5 /home/hmb/catalina_5_19

Note the permissions on the directories as well as the files.

From your first post it appears that you can read a file if it is there


and


write one as well. The real issue is in creating a directory. Is this
correct?

Doug
www.parsonstechnical.com



----- Original Message ----- From: "Christoph Meier" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Thursday, April 29, 2004 7:28 PM
Subject: Re: writing to File-System; IOException on File.mkdirs() and/or
File.createNewFile()







Hi

today i was debugging a lillte bit deeper (into sdk 1.4.2) to find out
where the IOException ecatly is thrown ...
in my desperation i also tried an alternative jre (blackdown); the
debugging i did with standard sun j2se

... may be this can help somebody to give me the final hint.

at the end of this mail i attach the script i'm using to start Tomcat
(onto which i added a "umask 006" ...)

-> debugging aFile.mkdirs()
-----------------------------------------------------
public class File implements java.io.Serializable, Comparable {
// ...
static private FileSystem fs = FileSystem.getFileSystem();

public boolean mkdirs() {
 if (exists()) {
     return false;
 }
 if (mkdir()) {
      return true;
  }
     File canonFile = null;
     try {
         canonFile = getCanonicalFile();
     } catch (IOException e){      // -> 1
         return false;
     }
 String parent = canonFile.getParent();
     return (parent != null) && (new File(parent).mkdirs() &&
canonFile.mkdir());
 }
// ...
 public File getCanonicalFile() throws IOException {
    return new File(getCanonicalPath());
 }
// ...
 public String getCanonicalPath() throws IOException {
   return fs.canonicalize(fs.resolve(this));
 }

// ...

}
--------------------------------------------

Exception is thrown at (1) in >>mkdirs()<<
when calling >>getCanonicalFile()<<
the IOException is passed from >>getCanonicalPath()<<
within >>getCanonicalPath()<< it is >>fs.canonicalize()<< which


fails.


fs<< is the plattform-dependant Implementation of abstract


java.io.FileSystem , for which i had no Source-Code to debugg into;
actually it is java.io.UnixFileSystem, and i know how it looks like
(see





http://www.cs.purdue.edu/homes/palsberg/cs565/java-source/java.1.2.2/src/so


laris/classes/java/io/UnixFileSystem.java




, maybe there is a newer version somewhere )

in UnixFileSystem (see Link above)  >>canonicalize()<< calls a native
method;
#---- snippet ----
public native String canonicalize(String path) throws IOException;
#----------------


the stack trace when calling directly >>aFile.getCanonicalPath()<< im my TestService looks like: -> .#------------------------------------- java.io.IOException: Bad pathname at java.io.UnixFileSystem.canonicalize0(Native Method) at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:154) at java.io.File.getCanonicalPath(File.java:513) at ch.hmb.app.service.TestService.writeTo(TestService.java:78) #--------------------------------------- .. the "Bad pathname" is nothing else than "home/hmb/catalina_5_19/webapps/hmb/a/1.txt" which should't be that bad ...(i guessed) ... later on in my TestService ... when calling >>aFile.createNewFile()<< next Exception is thrown #------------------------------------------------------------------ at java.io.UnixFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(File.java:828) at ch.hmb.app.service.TestService.writeTo(TestService.java:94) #---------------------------------------------------- ... but that's no more mistery since >>mkdirs()<< already failed




below are the stacks from the Exceptions thrown when using blackdown-jre ... looks the same #------------------------------------- java.io.IOException: Bad pathname at java.io.UnixFileSystem.canonicalize0(Native Method) at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:154) at java.io.File.getCanonicalPath(File.java:513) at ch.hmb.app.service.TestService.writeTo(TestService.java:78) #--------------------------------------- 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:94) #----------------------------------------------------


to finish i would like to emphasise again, that i still have another
Class "Test" which works fine concerning


mkdirs()<< and >>createNewFile()<< when i start it directly from the


shell (without Tomcat)

->
[EMAIL PROTECTED]:~$ /usr/java/bin/java Test
/home/hmb/catalina_5_19/webapps/hmb/1/2/3/4/myFile.txt
-> and the File is written!!!

well, i still hope to find a solution ... may be someone has a good




hint?




thanks,
regards,
christoph



############## start-script ########################
JAVA_HOME=/usr/java
JAVA_OPTS="${JAVA_OPTS} -XX:NewSize=48m -XX:MaxNewSize=48m
-XX:SurvivorRatio=8 -Xms128m -Xmx512m"
CATALINA_OPTS=
CATALINA_BASE=/home/hmb/catalina_5_19
CATALINA_HOME=$CATALINA_BASE
CATALINA_TMPDIR="$CATALINA_BASE"/webapps/hmb
JAVA_ENDORSED_DIRS="$CATALINA_HOME"/common/endorsed

CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

. $CATALINA_HOME/bin/custom.sh

umask 006

exec $CATALINA_HOME/bin/jsvc $JAVA_OPTS $CATALINA_OPTS \
  -user tomcat5 \
              -nodetach \
  -home $JAVA_HOME \
              -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" \
              -Dcatalina.base=$CATALINA_BASE \
  -Dcatalina.home=$CATALINA_HOME \
  -Djava.io.tmpdir=$CATALINA_TMPDIR \
  -outfile /home/hmb/catalina_5_19/logs/catalina.out \
  -errfile '&1' \
  $CATALINA_OPTS \
  -cp $CLASSPATH \
  org.apache.catalina.startup.Bootstrap

############ EOF: start-script ########################





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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




















--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to