Skip to content

consider switching to using resteasy-servlet-initializer #33

Description

@mdhtr

This application currently uses programmatic servlet registration in JettyServer.java:

JettyServer.java:90-95

private void addRestEasyServlet(ServletContextHandler contextHandler) {
    ServletHolder restEasyServlet = new ServletHolder(new HttpServletDispatcher());
    restEasyServlet.setInitParameter(RESTEASY_SERVLET_MAPPING_PREFIX, REST_API_BASE_PATH);
    restEasyServlet.setInitParameter(JAVAX_WS_RS_APPLICATION, JavaxWsRsApplication.class.getName());
    restEasyServlet.setInitParameter(RESTEASY_PROVIDERS, getExceptionMappers());
    contextHandler.addServlet(restEasyServlet, REST_API_BASE_PATH + ANY_PATH);
}

The resteasy-servlet-initializer would provide a ServletContainerInitializer implementation that auto-discovers JAX-RS Application classes and sets up RESTEasy automatically via the Servlet 3.0+ @HandlesTypes mechanism. This is useful when you have a web.xml with metadata-complete="false" and want automatic setup.

However, this application:

  • Has no web.xml (no src/main/webapp directory)
  • Manually instantiates HttpServletDispatcher
  • Manually configures init parameters
  • Manually registers the servlet with Jetty's ServletContextHandler
  • The auto-discovery mechanism is completely bypassed by the programmatic setup.

What resteasy-servlet-initializer does (that is not used here)

  • Scans for classes implementing jakarta.ws.rs.core.Application
  • Auto-registers the HttpServletDispatcher servlet
  • Auto-configures servlet mappings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions