On 10/03/2015 16:41, Emmanuel Franquemagne wrote: > Hello, > > Here is the description of my problem: I have a REST webservice > hosted in a tomcat instance and which is accessed by automated > processes; these processes request information about business objects > and take decision accordingly. Especially, when business object isn't > available, the webservice returns http code 404. > > Our problem is that Tomcat also returns 404 when the webservice isn't > started. It is fine from Tomcat point of view, but not from client > application pov: in this context, it is "normal" to get a "resource > not found" which has an applicative meaning, but from client side > point of view, down webapp is a internal ws error, and should be > returned 50x code (500, 501, 503...). And client must make difference > between "business object unknown" and "application unavailable". > > So my question is: is it possible to force Tomcat to return *50x* > code if a webapp it hosts is not started (or crashed or so), and let > *applicative 404* go to client? I've searched the Web to see if other > REST webapp developers had this issue, but found nothing. I may also > have misread tomcat manuel, but didn't find an answer to my > question.
It you want Tomcat to return something other than a 404 for a resource that doesn't exist you'll need to deploy something to do that. The simplest way may be to deploy a servlet to the ROOT web app mapped to /yourapp that returns a 503. If a context is deployed to /yourapp the Servlet mapping rules mean any requests will go to that app, not the ROOT app. If no context is deployed to /yourapp, the requests go to ROOT which will return the 503 (or whatever). Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org