Listing all deployed rest endpoints (spring-boot, jersey)

Probably the best way to do this, is to use an ApplicationEventListener. From there you can listen for the “application finished initializing” event, and get the ResourceModel from the ApplicationEvent. The ResourceModel will have all the initialized Resources. Then you can traverse the Resource as others have mentioned. Below is an implementation. Some of the … Read more

Jersey ContainerRequestFilter not triggered

Okay, I didn’t get that the jersey.config.server.provider.packages init param needs to reference not only service classes (API endpoints) but ALL the classes including filters. Now it works : <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.hck.debate.rest.controller;com.hck.debate.rest.security</param-value> </init-param> <init-param> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> <param-value>com.hck.debate.rest.security.AuthFilter</param-value> </init-param>

MULTIPART_FORM_DATA: No injection source found for a parameter of type public javax.ws.rs.core.Response

Get rid of jersey-multipart-1.18.jar. That is for Jersey 1.x. Add these two jersey-media-multipart-2.17 mimepull-1.9.3 For Maven you would use the following dependency (you don’t need to explicitly add the mimepull dependency, as this one will pull it in). <dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-multipart</artifactId> <version>2.17</version> <!– Make sure the Jersey version matches the one you are currently using … Read more

What exactly is the ResourceConfig class in Jersey 2?

Standard JAX-RS uses an Application as its configuration class. ResourceConfig extends Application. There are three main ways (in a servlet container) to configure Jersey (JAX-RS): With only web.xml With both web.xml and an Application/ResourceConfig class With only an Application/ResourceConfig class annotated with @ApplicationPath. With only web.xml It is possible to configure the application in a … Read more

Dependency injection with Jersey 2.0

You need to define an AbstractBinder and register it in your JAX-RS application. The binder specifies how the dependency injection should create your classes. public class MyApplicationBinder extends AbstractBinder { @Override protected void configure() { bind(MyService.class).to(MyService.class); } } When @Inject is detected on a parameter or field of type MyService.class it is instantiated using the … Read more

Jersey stopped working with InjectionManagerFactory not found

Add this dependency: <dependency> <groupId>org.glassfish.jersey.inject</groupId> <artifactId>jersey-hk2</artifactId> <version>2.28</version> </dependency> cf. https://stackoverflow.com/a/44536542/1070215 Make sure not to mix your Jersey dependency versions. This answer says version “2.28”, but use whatever version your other Jersey dependency versions are.

How to implement REST token-based authentication with JAX-RS and Jersey

How token-based authentication works In token-based authentication, the client exchanges hard credentials (such as username and password) for a piece of data called token. For each request, instead of sending the hard credentials, the client will send the token to the server to perform authentication and then authorization. In a few words, an authentication scheme … Read more