I have created a Dynamic Web Projects named "test" using Eclipse WTP Tomcat, Eclipse version is Java EE Kepler Service Release 2, Tomcat version is 7.0.53, Servlet 3.0, Win 8.1 x86, jdk 1.6.0_45, but after several tries, I found the problem occurs when matching all the following conditions:
- the Webapp(web context) is not in <CATALINA_HOME>/webapps(which is the default value of appBase) and:
- the Webapp is configured by writing a <Context> element in <CATALINA_HOME>\conf\server.xml, under the <Host> element.
Here is part of <CATALINA_HOME>\conf\server.xml:
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/>
<Context docBase="D:/tmpdev/apache-tomcat-7.0.53/wtpwebapps/test" path="/test" reloadable="true"/>
</Host>
and here is the Directory Structure of "test":
test
├─META-INF
│ MANIFEST.MF
│
└─WEB-INF
│ web.xml
│
├─classes
│ └─test
│ HelloServlet.class
│ MyFilter1.class
│ MyFilter2.class
│ MyHttpSessionListener.class
│ MyServletContextListener.class
│
└─lib
Although WEB-INF/web.xml is <WatchedResource> in <CATALINA_HOME>\conf\context.xml by default, I tried to add a <WatchedResource> element in each of the following formats, still not works:
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF\web.xml</WatchedResource>
<WatchedResource>D:/tmpdev/apache-tomcat-7.0.53/wtpwebapps/test/WEB-INF/web.xml</WatchedResource>
<WatchedResource>D:\tmpdev\apache-tomcat-7.0.53\wtpwebapps\test\WEB-INF\web.xml</WatchedResource>
HERE is other configuration ways that works:
- use a seperate file <CATALINA_HOME>\conf\Catalina\localhost\test.xml to configure context, or:
- move "test" into <CATALINA_HOME>\webapps without any more configuration, or:
- check "Serve modules without publishing" of Server Options in Eclipse WTP