Category Archives: Tomcat

Tomcat Startup in Eclipse – ‘Document base does not exist or is not a readable directory’

Published by:

When I try to start the Tomcat server in Eclipse, the following stacktrace appears on the console:

Dec 7, 2012 12:59:18 AM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /Users/mychin/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Chapter1XML does not exist or is not a readable directory
 at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)
 at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4320)
…
(more)

 

Solution

  1. On the ‘Servers’ tab in Eclipse, right-click on the current Tomcat server and delete it.
  2. On the ‘Servers’ tab, right-click the white area and choose New > Server > Tomcat v6.0 Server to re-create new server.
  3. Restart the server again and the problem should be resolved.

Running Tomcat Standalone in IntelliJ IDEA

Published by:

If you try to deploy a web application in Intellij IDEA without specifying the location of the Tomcat standalone, Intellij IDEA will create a hidden directory in the user’s home directory and copy the Tomcat’s conf directory into the hidden directory. The file path will be as following: /home/yee/.IntelliJIdea90/system/tomcat

In order to fix the problem, you need to edit the Tomcat configuration file and add the environment variable which you can edit it via Run > ‘Edit Configuration’ > Startup/Connection tab and add the following:

Name: CATALINA_BASE
Value: /usr/local/tomcat

The value depends on the path that you had set for the installation of the Tomcat standalone in your machine.

Installing Tomcat 7 on Ubuntu

Published by:

I just followed the steps provided by this site to install Tomcat 7 on Ubuntu:

Please remember to change the location or the site where you want to download Tomcat 7 as the provided URL is for Tomcat 6. This also depends which beta version that you are trying to install as well. You can refer to this page about this version and copy the URL and use it with the wget command. For example, I’m downloading v7.0.4-beta and the command that I’m using is:

sudo wget http://apache.hoxt.com/tomcat/tomcat-7/v7.0.4-beta/bin/apache-tomcat-7.0.4.tar.gz

Everything is working fine except when I tried to configure the Tomcat in Eclipse, I encountered a failure to start the server:

Could not load the Tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config. The configuration may be corrupt or incomplete.

If compare with the projects that I had copied from the previous laptop, I should have the following files in the <eclipse workspace>/Servers/<Tomcat version> Server at localhost-config:

  • catalina.policy
  • catalina.properties
  • context.xml
  • server.xml
  • tomcat-users.xml
  • web.xml

When I checked my current Eclipse workspace, the listed files do not exist in the intended directory. To resolve the problem, you need to copy those files from /usr/local/tomcat/conf directory to the intended location:

yee@chimney:/usr/local/tomcat/conf$ ls -la
total 100
drwxr-xr-x 2 root root 4096 2010-10-15 07:27 .
drwxrwxr-x 9 root root 4096 2010-10-24 12:46 ..
-rw——- 1 root root 10650 2010-10-15 07:27 catalina.policy
-rw——- 1 root root 4990 2010-10-15 07:27 catalina.properties
-rw——- 1 root root 1394 2010-10-15 07:27 context.xml
-rw——- 1 root root 3152 2010-10-15 07:27 logging.properties
-rw——- 1 root root 6268 2010-10-15 07:27 server.xml
-rw——- 1 root root 1530 2010-10-15 07:27 tomcat-users.xml
-rw——- 1 root root 51579 2010-10-15 07:27 web.xml
yee@chimney:/usr/local/tomcat/conf$ sudo cp * /home/yee/eclipseWorkspace/Servers/Tomcat v7.0 Server at localhost-config/


Also, remember to change the permission for all the files else you will still encounter the error such as:

Could not read file: /home/yee/eclipseWorkspace/Servers/Tomcat v7.0 Server at localhost-config/server.xml.
/home/yee/eclipseWorkspace/Servers/Tomcat v7.0 Server at localhost-config/server.xml (Permission denied)

That’s it. No more errors :)