aspose file tools*
The moose likes Tomcat and the fly likes java.lang.IllegalArgumentException: Document base dir does not exist or is not a readable directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "java.lang.IllegalArgumentException: Document base dir does not exist or is not a readable directory" Watch "java.lang.IllegalArgumentException: Document base dir does not exist or is not a readable directory" New topic
Author

java.lang.IllegalArgumentException: Document base dir does not exist or is not a readable directory

Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
Would someone tell me why I may be getting this error? Am I missing something between the double quotes?

Sep 12, 2013 10:30:26 PM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /usr/share/tomcat/webapps/usr/share/tomcat/webapps/examples does not exist or is not a readable directory

Here's a snip from the server.xml
<Context path=""
docBase="usr/share/tomcat/webapps/examples"
debug="0" reloadable="true" />

Searching the forum I found a similar post.

http://www.coderanch.com/t/86668/Tomcat/running-simple-Servlet-Tomcat

I've checked the server.xml file for the word "context" and there's only the one instance stated up above. I've checked the spelling. And I've searched for server.xml to ensure I only have one such file on the server. If you need more info let me know.

Thanks in advance.

Debian 7

# java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I think that by making your "docbase" attribute refer to a relative path, you have caused it to refer to a nonexistent directory.

(And since this is a Tomcat question I'm going to move it to the Tomcat forum.)
Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
The subdirectory /usr/share/tomcat/webapps/example does exist. It's owned by the tomcat user and tomcat group. I logged in as tomcat, and used touch to create a file in it. I'm really wondering why I see it doubled up like that.
Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
Paul Clapham wrote:I think that by making your "docbase" attribute refer to a relative path, you have caused it to refer to a nonexistent directory.

(And since this is a Tomcat question I'm going to move it to the Tomcat forum.)


Paul thanks for moving it to the Tomcat forum, my mistake.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Jim Armstrong wrote:The subdirectory /usr/share/tomcat/webapps/example does exist. It's owned by the tomcat user and tomcat group. I logged in as tomcat, and used touch to create a file in it. I'm really wondering why I see it doubled up like that.


Well, like I said it's because you didn't actually specify the subdirectory /usr/share/tomcat/webapps/example. Instead you specified the relative path usr/share/tomcat/webapps/example. You can tell what Tomcat's current working directory is by subtracting that path of the end of the path in the error message, but having to know what Tomcat's working directory is is a bad strategy. Just specify the absolute path.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

Your Tomcat server's default webapp base is located at /usr/share/tomcat/webapps. By using the relative path " usr/share/tomcat/webapps/examples" you have constructed the path " /usr/share/tomcat/webapps/usr/share/tomcat/webapps/examples".

THAT directory, I will wager does NOT exist.

The proper context path in relative terms would be simply "examples", not " usr/share/tomcat/webapps/examples".

The better choice for context path would be " /usr/share/tomcat/webapps/examples" (absolute path).

I actually prefer to deploy my webapps to external locations, so my Context bases are more like "/opt/com/mousetech/product1/product1.war".

Relative paths are dangerous, though. Regardless of where you deploy, I recommend using an absolute path to reference it.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
Tim Holloway wrote:Your Tomcat server's default webapp base is located at /usr/share/tomcat/webapps. By using the relative path " usr/share/tomcat/webapps/examples" you have constructed the path " /usr/share/tomcat/webapps/usr/share/tomcat/webapps/examples".

THAT directory, I will wager does NOT exist.

The proper context path in relative terms would be simply "examples", not " usr/share/tomcat/webapps/examples".

The better choice for context path would be " /usr/share/tomcat/webapps/examples" (absolute path).

I actually prefer to deploy my webapps to external locations, so my Context bases are more like "/opt/com/mousetech/product1/product1.war".

Relative paths are dangerous, though. Regardless of where you deploy, I recommend using an absolute path to reference it.


Tim that wager would have been easy money.
Many thanks to both of you for squaring me away. Setting it as the absolute path resolved the error.

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html This link was helpful too. Passing it along for the next greenhorn who stumbles down this path.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.IllegalArgumentException: Document base dir does not exist or is not a readable directory