wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Problem running simple Servlet on Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Problem running simple Servlet on Tomcat" Watch "Problem running simple Servlet on Tomcat" New topic
Author

Problem running simple Servlet on Tomcat

Idris Pathan
Greenhorn

Joined: Feb 16, 2007
Posts: 4
I am having problems trying to get a simple servlet to run on Tomcat6.0 on WinXP
I am seeing the following error

SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\webapps\MyFristApp does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:141)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3941)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4112)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
16-Feb-2007 22:48:59 org.apache.catalina.core.StandardContext start


My set up is as follows

C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MyFristApp
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MyFristApp\Images
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MyFristApp\META-INF
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MyFristApp\WEB-INF\classes
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MyFristApp\WEB-INF\lib
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MyFristApp\WEB-INF\web.xml

In my server.xml file I have added the following

<Context path="/MyFirstApp" docBase="MyFirstApp" crossContext="true" debug="0" reloadable="true" trusted="false"></Context>


any one know whey I am seeing the error

java.lang.IllegalArgumentException: Document base C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\webapps\MyFristApp does not exist or is not a readable directory.


Thanks in advance for any help.

[ February 16, 2007: Message edited by: IdrisK ]

[ February 16, 2007: Message edited by: IdrisK ]
[ February 16, 2007: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

If you check the message carefully:

you will see that the path specified does not match your setup.

How are you addressing the servlet such that there's an extra webapps in there?

Also, check your spelling of "First".
[ February 16, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Idris Pathan
Greenhorn

Joined: Feb 16, 2007
Posts: 4
Thanks for the reply Bear Bibeault,

Yes changed my setup to
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\webapps\MyFirstApp
so that it is the same as my Context path in server.xml

Context path="/MyFirstApp" docBase="MyFirstApp" crossContext="true" debug="0" reloadable="true" trusted="false"></Context>



But still getting the error

java.lang.IllegalArgumentException: Document base C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\webapps\MyFristApp does not exist or is not a readable directory.

I am not sure where this path is coming from, I have checked the server.xml
The web.xml is as follows.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
<servlet>
<servlet-name>

</servlet-name>
<servlet-class>

</servlet-class>
<init-param>
<param-name>
Log
</param-name>
<param-value>
C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin
</param-value>
</init-param>
<param-name>
Path
</param-name>
<param-value>
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MyFristApp
</param-value>
</init-param>
<init-param>
<param-name>
Port
</param-name>
<param-value>
1998
</param-value>
</init-param>

</servlet>
<servlet>
<servlet-name>

</servlet-name>

</servlet-class>
<init-param>
<param-name>
Log
</param-name>
<param-value>
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MyFirstApp\Logs
</param-value>
</init-param>
<init-param>
<param-name>
Path
</param-name>
<param-value>
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MyFirstApp
</param-value>
</init-param>
<init-param>
<param-name>
Port
</param-name>
<param-value>
2001
</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>

</servlet-name>
<url-pattern>
/patcher.html
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
Manager
</servlet-name>
<url-pattern>
/Manager.html
</url-pattern>
</servlet-mapping>
</web-app>


Any ideas as to where its picking this path up from?
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\webapps\MyFristApp
[ February 16, 2007: Message edited by: Idris Pathan ]
Micky Danese
Greenhorn

Joined: Sep 22, 2011
Posts: 2
Check your server.xml file (tomcathome/conf/server.xml)
is there a <context> element with a reference to the problem directory?
yes : remove it.
Santiago Carrillo
Greenhorn

Joined: Jan 27, 2012
Posts: 1
In Eclipse: Just go to the server that you have configured , right click -> Add and Remove: and then remove all the not used projects or the ones that you have deleted before, the error should not come anymore !
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Who's said eclipse was being used?
 
jQuery in Action, 2nd edition
 
subject: Problem running simple Servlet on Tomcat