2

Currently i am working on an issue where if content-type format is invalid (type/subtype , where "/" is missing), jetty sends response back as 400. I need to customize the error message using whiteboard pattern (osgi.service.http.whiteboard). I registered a new servlet with the errorpage pattern as "400" like the following:

@Component(
    service=Servlet.class,
    property= {
        "osgi.http.whiteboard.servlet.errorPage=java.lang.IllegalArgumentException",
        "osgi.http.whiteboard.servlet.errorPage=400"
    },
scope=ServiceScope.PROTOTYPE)
public class ErrorServlet extends HttpServlet{}

However I am facing the issue that is: in spite of an error code "400" sent from Jetty my servlet(ErrorServlet) is not getting called to handle it.

ajay gupta
  • 41
  • 2
  • You didn't mention which Whiteboard Service implementation you're using. – Grzegorz Grzybek Jun 25 '20 at 10:29
  • I may be wrong in understanding the answer ... i am using org.osgi.service.http.whiteboard. is that what u were asking . basically I was following the documentation of osgi whiteboard documentation to write the code. Please correct me if I misunderstood your point. – ajay gupta Jun 25 '20 at 10:43
  • Since you are working with OSGi and Error handling, make sure you are running the latest stable version of Jetty (lots of work in that area in the code). Use version `9.4.30.v20200611` – Joakim Erdfelt Jun 25 '20 at 13:48
  • I meant - the `ErrorServlet` you've presented is compiled and packaged as bundle. Where do you run this bundle? In which OSGi runtime? (Karaf? Felix? Equinox? other?) What is the Whiteboard implementation that's running in this OSGi runtime? (Pax-Web? Felix.Http?) – Grzegorz Grzybek Jun 26 '20 at 04:43

0 Answers0