Search code examples
osgijax-rsequinoxcustom-error-pages

Suppressing the Jetty error pages when using the embedded jetty server within Equinox (OSGi)


I am using the embedded Jetty server that comes with Equinox (not the jetty bootstrap) along with Jersey to provide a JAX-RS API for my user interface, which is pure html5/css3/JavaScript

The problem is that for certain error states Jetty provides an error page. This is a problem because I am using various state codes along with xml/json entities as a part of how my API works.

I don't want any html sent to my API clients.

I am also making use of the OSGi JAX-RS connector, so I don't have access to a web.xml in my application bundles. The JAX-RS components are deployed as OSGi services and dynamically registered with Jersey.

Does anyone know how to turn off the error pages so that my entities are not suppressed and no html is generated when using Jetty in this configuration?

The JARs I am using for jetty are:

  • org.eclipse.equinox.http.jetty_3.0.100.v20130327-1442.jar
  • org.eclipse.jetty.continuation_8.1.10.v201312.jar
  • org.eclipse.jetty.http_8.1.10.v201312.jar
  • org.eclipse.jetty.jetty.io_8.1.10.v201312.jar
  • org.eclipse.jetty.jetty.security_8.1.10.v201312.jar
  • org.eclipse.jetty.jetty.server_8.1.10.v201312.jar
  • org.eclipse.jetty.jetty.servlet_8.1.10.v201312.jar
  • org.eclipse.jetty.jetty.util_8.1.10.v201312.jar
  • Kind Regards,

    Jason.


    Solution

  • Have you tried to implementing org.eclipse.equinox.http.jetty.JettyCustomizer to customize jetty server and to provide custom error handler. You have to define a system property org.eclipse.equinox.http.jetty.customizer.class and specify qualified name of you class in order for jetty to use this customizer