Maven Coordinates

To enable Jersey (JAX-RS) Support add the following dependency to your project’s pom.xml (see Managing Dependencies).

<dependency>
    <groupId>io.helidon.webserver</groupId>
    <artifactId>helidon-webserver-jersey</artifactId>
</dependency>
Copied

JAX-RS Support

You can register a Jersey (JAX-RS) application at a context root using the JerseySupport class.

Registering a Jersey Application

To register a Jersey application at a context root, use the JerseySupport class and its JerseySupport.Builder builder.

JerseySupport can register the JAX-RS resources directly.

Jersey (JAX-RS) HelloWorld resource
@Path("/")
public class HelloWorld {

    @GET
    @Path("hello")
    public Response hello() {
        return Response.ok("Hello World!").build();
    }
}
Copied
Registering the HelloWorld resource
Routing.builder()
       .register("/jersey", 
                 JerseySupport.builder()
                              .register(HelloWorld.class) 
                              .build())
       .build();
Copied
  • Register the Jersey application at /jersey context root
  • The Jersey Application stays hidden and consists of a single HelloWorld resource class

As a result, an HTTP GET request to /jersey/hello would yield a Hello World! response string.

Registering a JAX-RS Application

You can also register the JAX-RS Application object.

Register the HelloWorld resource
Routing.builder()
       .register("/jersey", 
                 JerseySupport.builder(new MyApplication()) 
                              .build())
       .build();
Copied
  • Register the Jersey application at /jersey context root
  • MyApplication handles requests made to /jersey context root.

Accessing WebServer Internals from a JAX-RS Application

You can inject WebServer request and response objects into your JAX-RS application using @Context.

Injection of WebServer internal objects
@Path("/")
@RequestScoped
public class HelloWorld {
    @Context
    private ServerRequest request;

    @Context
    private ServerResponse response;
}
Copied