You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Horacio de Oro <ho...@trimaxcba.com> on 2004/07/16 19:49:10 UTC
[Daemon] File.mkdirs() don't work if started with jsvc
Hi again!
I was trying File.mkdirs() on Tomcat 5.0.25 on Debian Woody, and I can
say File.mkdirs() don't work if Tomcat is started with jsvc.
(I've to say that this happens ONLY on Debian Woody... Debian Sarge and
Debian Sid works ok).
I've made a simple servlet (since Tomcat can't compile JSP):
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet</title>");
out.println("</head>");
try {
String fileName = "/tmp/test/" +
System.currentTimeMillis() +
"/test/afile.txt";
out.println("File name: " + fileName + "<br>");
File file = new File(fileName);
boolean ok = file.mkdirs();
if(ok)
out.println("OK<br>");
else
out.println("FAIL without exception!<br>");
} catch(Exception e) {
out.println("FAIL with exception!<br>");
out.println("<pre>");
StackTraceElement el[] = e.getStackTrace();
out.println(e.getMessage());
for(int i=0; i<el.length; i++) {
out.print(" ");
out.println(el[i].toString());
}
out.println("</pre>");
}
out.println("<body>");
out.println("</body>");
out.println("</html>");
out.close();
}
If I start Tomcat with "startup.sh", I get:
============================================================
File name: /tmp/test/1089999282783/test/afile.txt
OK
============================================================
If I start Tomcat with "jsvc", I get:
============================================================
File name: /tmp/test/1089999639863/test/afile.txt
FAIL without exception!
============================================================
I'll post whis message on tomcat-user and commons-user, because maybe
this could be a jsvc related problem
Thanks in advance!
Horacio
FYI: # java -version
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)
PS: here is my original post on tomcat-user:
Horacio de Oro wrote:
> Hi! What a subject!
>
> I've trying to make work starting up Tomcat with jsvc.
> On Debian unstable, this works ok.
> On Debian stable (woody), I could startup Tomcat, but when I try to
> access to a JSP file, I get the classic exception:
>
> 2004-07-12 02:03:58 StandardWrapperValve[jsp]: Servlet.service() for
> servlet jsp threw exception
> java.io.FileNotFoundException:
> /home/horacio/tomcat-pruebas-startup/jakarta-tomcat-5.0.25/work/Catalina/localhost/prueba/org/apache/jsp/test_jsp.java
>
> at java.io.FileOutputStream.open(Native Method)
> at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
> at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
> at
> org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:188)
>
> This isn't a permission problems, I've checked them a hundred times,
> I've excecute 'chown -R USER.USER jakarta-tomcat-dir' many times too.
>
> I've follow the instructions on Tomcat FAQ, and I've tryed
> http://jakarta.apache.org/tomcat/faq/misc.html#commonsLoggingLog4j
> http://marc.theaimsgroup.com/?l=tomcat-user&m=108330970225012&w=2
> http://marc.theaimsgroup.com/?l=tomcat-user&m=108578233003073&w=2
>
> and couldn't make it work on Debian stable (woody).
>
> I was looking at 'generateJava()' on file
> org.apache.jasper.compiler.Compiler.java (line 188), this is what make
> the exception:
>
> try {
> osw = new OutputStreamWriter( // <- LINE 188
> new FileOutputStream(javaFileName), javaEncoding);
>
> } catch (UnsupportedEncodingException ex) {
> errDispatcher.jspError("jsp.error.needAlternateJavaEncoding",
> javaEncoding);
> }
>
> So, I make a little java program using FileOutputStream.
>
> public static void main(String[] args) throws Exception {
> FileOutputStream fos = new
> FileOutputStream("/tmp/dir/that/doesnt/exist/test.txt");
> byte test[] = new byte[1024];
> fos.write(test);
> fos.close();
> }
>
> Since "/tmp/dir/that/doesnt/exist" doesn't existe, I get the exact same
> exception:
>
> java.io.FileNotFoundException:
> at java.io.FileOutputStream.open(Native Method)
> at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
> at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
>
>
>
> And then, I've tried to make the directories that Tomcat needs to make
> the temporary .java, so I do:
>
> mkdir -p
> /home/horacio/tomcat-pruebas-startup/jakarta-tomcat-5.0.25/work/Catalina/localhost/prueba/org/apache/jsp
>
>
> and then, reloaded the page, and this work!!!!!
>
> So, the only problem is that Tomcat doesn't make the proper directory
> structure where it should put the generated .java...
>
> So:
> - If I run Tomcat from "startup.sh" -> WORKS
> - If I run Tomcat from "jsvc" on UNSTABLE -> WORKS
> - If I run Tomcat from "jsvc" on STABLE -> DOESN'T WORKS
>
> ON DEBIAN UNSTABLE:
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
>
> ON DEBIAN STABLE:
> java version "1.4.2"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
> Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
>
> ALSO ON DEBIAN STABLE:
> java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
>
> Tomcat 5.0.25
>
> Is this a bug?
> How can I make work Tomcat on Debian stable with jsvc?
>
> Thanks in advance!
>
> Horacio de Oro
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Daemon] File.mkdirs() don't work if started with jsvc
Posted by Horacio de Oro <ho...@trimaxcba.com>.
Kees Jongenburger wrote:
> On Friday 16 July 2004 07:49 pm, Horacio de Oro wrote:
>
>>Hi again!
>>
>>I was trying File.mkdirs() on Tomcat 5.0.25 on Debian Woody, and I can
>>say File.mkdirs() don't work if Tomcat is started with jsvc.
>>
>>(I've to say that this happens ONLY on Debian Woody... Debian Sarge and
>>Debian Sid works ok).
>
>
> Hi . if you have installed tomcat using apt-get it might just be the security settings that debian developers
> like to add to tomcat. Have you tried to download tomcat and insall by hand?
> (editing /etc/tomcatthingy) does not work since they also used to override those files every startup
>
>
Hi!
I've installed tomcat from "jakarta-tomcat-5.0.25.tar.gz"...
On "jsvc-src/native/jsvc-unix.c":
/* Set linux capability, user and group */
#ifdef OS_LINUX
/* CAPSALL is to allow to read/write at any location */
#define CAPSALL (1 << CAP_NET_BIND_SERVICE)+ \
(1 << CAP_SETUID)+ \
(1 << CAP_SETGID)+ \
(1 << CAP_DAC_READ_SEARCH)+ \
(1 << CAP_DAC_OVERRIDE)
#define CAPSMAX (1 << CAP_NET_BIND_SERVICE)+ \
(1 << CAP_DAC_READ_SEARCH)+ \
(1 << CAP_DAC_OVERRIDE)
/* That a more reasonable configuration */
#define CAPS (1 << CAP_NET_BIND_SERVICE)+ \
(1 << CAP_SETUID)+ \
(1 << CAP_SETGID)
/* probably the only one Java could use */
#define CAPSMIN (1 << CAP_NET_BIND_SERVICE)
I don't understand how to use "capabilities"... Could be some problem
related with capabilities??? (since the error apears ONLY if I start
Tomcat with jsvc)
Horacio
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Daemon] File.mkdirs() don't work if started with jsvc
Posted by Kees Jongenburger <ke...@dds.nl>.
On Friday 16 July 2004 07:49 pm, Horacio de Oro wrote:
> Hi again!
>
> I was trying File.mkdirs() on Tomcat 5.0.25 on Debian Woody, and I can
> say File.mkdirs() don't work if Tomcat is started with jsvc.
>
> (I've to say that this happens ONLY on Debian Woody... Debian Sarge and
> Debian Sid works ok).
Hi . if you have installed tomcat using apt-get it might just be the security settings that debian developers
like to add to tomcat. Have you tried to download tomcat and insall by hand?
(editing /etc/tomcatthingy) does not work since they also used to override those files every startup
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Daemon] File.mkdirs() don't work if started with jsvc
Posted by Horacio de Oro <ho...@trimaxcba.com>.
Michael McGrady wrote:
> At 10:49 AM 7/16/2004, you wrote:
>
>> (I've to say that this happens ONLY on Debian Woody... Debian Sarge and
>> Debian Sid works ok).
>
> Try getting ird of the hard coded separators, i.e. "/", with
> File.separator, e.g. File.separator + "tmp" + File.separtor + "test+
> File.separator instead of "/tmp/test/". Don't do this with the content
> types, by the way. If you want to be OS free, you have to code OS free.
>
> Michael
>
>
Hi Michael!
With:
String fileName = File.separator + "tmp" +
File.separator + "test" +
File.separator + System.currentTimeMillis() +
File.separator + "test" +
File.separator + "lastDir";
I get:
======================================================
File name: /tmp/test/1090002159068/test/lastDir
FAIL without exception!
======================================================
The same problem! File.mkdirs() doesn't work!
Horacio
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [Daemon] File.mkdirs() don't work if started with jsvc
Posted by Michael McGrady <mi...@michaelmcgrady.com>.
At 10:49 AM 7/16/2004, you wrote:
>(I've to say that this happens ONLY on Debian Woody... Debian Sarge and
>Debian Sid works ok).
Try getting ird of the hard coded separators, i.e. "/", with
File.separator, e.g. File.separator + "tmp" + File.separtor + "test+
File.separator instead of "/tmp/test/". Don't do this with the content
types, by the way. If you want to be OS free, you have to code OS free.
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org