Sunday, February 13, 2011

Custom Error Pages in JBoss

Hey all, This is my first question here!

I'm trying to setup custom error pages in my JBoss RESTful web service. I'm starting with the 400 error, so in my web.xml I've added

<error-page>
 <error-code>400</error-code>
 <location>/400.html</location>
</error-page>

and I've placed 400.html at the root of my war file (I've also tried placing it at the root of WEB-INF). Unfortunately, I keep getting 404's when I'm supposed to get 400's, presumably because JBoss can't seem to find 400.html. Any ideas what I'm doing wrong?

Might it be because my servlets are mapped to the root?

<servlet-mapping>
 <servlet-name>api</servlet-name>
 <url-pattern>/</url-pattern>
</servlet-mapping>

if so, what are the alternatives?

Thanks!

  • For posterity: I was able to finally get this working by redirecting errors to a page that Spring MVC had a controller for. The controller just returned a null ModelAndView. Because it was a RESTful service, I really didn't need to have any HTML emitted anyway.

0 comments:

Post a Comment