Bug 66203 - Better error message than "llegalStateException: No output folder" in JspCompilationContext.createOutputDir()
Summary: Better error message than "llegalStateException: No output folder" in JspComp...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 9.0.37
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-04 10:27 UTC by Ralf Hauser
Modified: 2022-09-21 10:56 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Hauser 2022-08-04 10:27:54 UTC
in org.apache.jasper.JspCompilationContext.createOutputDir(JspCompilationContext.java:697), please

1) say which folder is attempted to be created
2) what userId the current tomcat is running under
3) what permission rights are found on the super-directory

This would make it a lot easier to diagnose.

Probably it was a permission rights problem as in
https://stackoverflow.com/questions/18348741/message-java-lang-illegalstateexception-no-output-folder
Comment 1 Konstantin Kolinko 2022-08-04 12:18:17 UTC
1. I do not like adding details like that to an exception message.

As can be seen from the stackoverflow link, the error message is being shown to a visitor of a web site.

Showing them installation details is a bad idea.


2. It should be possible to add a log statement.

E.g. the actual path of a directory.

Though note that

a. There exists a
org.apache.catalina.startup.VersionLoggerListener

It already logs valuable information.

b. A care would better be taken to do not flood the logs.

It should not be logged more often than usual JSP compilation errors, when Jasper is configured with development=false.


> 1) say which folder is attempted to be created

The "catalina.base" directory is logged.
It is possible to derive the rest of the path from there.


> 2) what userId the current tomcat is running under

This will be logged if VersionLoggerListener is configured with logProps=true. The "user.name" property is it.

Maybe it is worth to improve VersionLoggerListener to log a value of the "user.name" property unconditionally, by default.

Though if Tomcat is launched via jsvc, Tomcat may initialize under one user, and then start under another one.
 
https://commons.apache.org/proper/commons-daemon/jsvc.html


> 3) what permission rights are found on the super-directory

A failing File.mkdirs() call does not provide such details.

Also, what is meant by permissions differs between operating systems.
Comment 2 Mark Thomas 2022-09-21 10:52:05 UTC
I've added an ERROR level log message that reports the full path to the directory that can't be created. That should be sufficient for the system admin to debug the issue.

I agree with Konstantin that permissions management varies too much between operating systems for provision of more detailed debugging information to be practical.

The message gets logged once per compilation failure (not once per request to the JSP). Given that JSP compilation is fundamentally broken in these circumstances, that level of logging does not seem excessive.
Comment 3 Mark Thomas 2022-09-21 10:56:19 UTC
Fixed in:
- 10.1.x for 10.1.0-M21 onwards
- 10.0.x for 10.0.25 onwards
-  9.0.x for  9.0.66 onwards
-  8.5.x for  8.5.83 onwards