cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mandy Warren <mandys.in...@gmail.com>
Subject How to intercept exceptions thrown by CXF servlet
Date Sat, 22 Jun 2013 15:00:34 GMT

I have developed a REST service using Apache CXF and notice that if I send invalid characters
in the URL, the CXF servlet throws back the following exception before it gets to my code:

Servlet failed with Exception java.lang.IllegalArgumentException at java.net.URI.create(URI.java:841)
at org.apache.cxf.transport.servlet.BaseUrlHelper.getBaseURL(BaseUrlHelper.java:49) at org.apache.cxf.transport.servlet.ServletController.getBaseURL(ServletController.java:73)
at org.apache.cxf.transport.servlet.ServletController.updateDestination(ServletController.java:82)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:162) at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137) at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:239)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:164)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:215)
This results in a 500 status code being returned to the client.

I would ideally like to intercept this exception and return a 400 Bad Request status code
to the client but I am unable to work out how to do this.

Any help much appreciated!

Many thanks



Mime
  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message