Closed OlexYarm closed 1 year ago
Correct, it won't create the directory.
Be sure you have the directory created first, with the right permissions (and setuid/guide bits if needed)
We don't do this in our java code as the permissions for the directory are often wrong when we do it.
Also, when a user uses symlinks things get extra complicated.
I created the issue because of confusing error message. I spent some time trying to figure out why application "Cannot write log directory ". It could be simply fixed as following.
if (!dir.isDirectory()) { throw new IOException("Log directory does not exist. Directory path="+dir); } if (!dir.canWrite()) { throw new IOException("Cannot write log directory "+dir); }
@OlexYarm care to create a pull request? Thanks!
@OlexYarm care to create a pull request? Thanks!
Hi Simon, I made a fix with a few lines for bug in jetty-11.0.x and tested it locally on my Windows 11 desktop. I could not push commit to GitHub because i don't have write access to eclipse/jetty.project. Could I send it to you or somebody from Dev team, or should I ask repository admin to give me write access?
@OlexYarm typically you would create a fork of the project and commit your change to that, then create a pull request from your fork to the 10.0.x
branch, once it is reviewed and merged it will be merged forward to 11.0.x
and 12.0.x
branches.
Embedded Jetty server fails to start with IOException and confusing error message when requests log path settings in RequestLogWriter contains not existed directory: java.io.IOException: Cannot write log directory ...
The IOException with message is thrown from the class RolloverFileOutputStream.
path: root/jetty-util/src/main/java/org/eclipse/jetty/util/RolloverFileOutputStream.java package org.eclipse.jetty.util; ... public class RolloverFileOutputStream extends FilterOutputStream ... / ------------------------------------------------------------ / private synchronized void setFile() throws IOException { // Check directory File file = new File(_filename); _filename=file.getCanonicalPath(); file=new File(_filename); File dir= new File(file.getParent()); if (!dir.isDirectory() || !dir.canWrite()) throw new IOException("Cannot write log directory "+dir); ...
Also the class RolloverFileOutputStream does not try to create directory for requests log file. I encountered the bug while testing my example application with Jetty 11.0.15. I looked at source code of Jetty 12.0.0 and could see that the bug exists there also.