Wednesday, July 9, 2008

Web Application Configuration Using Java

I just spent 4+ hours on a bug that was extremely nuanced. If you name a servlet default, you will not be able to access any of the static pages. This means:

<web-app>
...
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
.....
</web-app>

will prevent all static content from being accessed through the application server. It will give you 404 errors as if the content doesn't exist. Hope this helps someone else save some time, it definitely cost me some.

For this problem, I was using Jetty with a open folder instead of a war file.