I am using glassfish Jersey JAX-RS on Java 11 and Tomcat 9 server. I upgraded my Jersey version to 2.27 recently after @Context object is coming null in my application. This object belongs to a 3rd party API.
The version of Jersey in the 3rd party API, having the context element, is 1.19 and also, it belongs to com.sun package and not the one I am using which is org.glassfish. My called Rest method looks like:
@GET
@Produces(MediaType.APPLICATION_JSON)
public Pageable<Role> getRoles(@Context final Search search) throws ServerException {
return new Pageable<>(identityManagementService.getRoles(), search);
}
which calls following :
public Pageable(final List<T> list, final Search search) {
this.count = list.size();
this.data = list;
if (search.getLimiter() != null && search.getLimiter().getCount() != 0) {
this.data = list.stream()
.skip(search.getLimiter().getOffset())
.limit(search.getLimiter().getCount())
.collect(Collectors.toList());
} }
3rd party Pom.xml has following entry :
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
<optional>true</optional>
<exclusions>
<exclusion>
<artifactId>asm</artifactId>
<groupId>asm</groupId>
</exclusion>
</exclusions>
</dependency>
I have following entry in my pom.xml:
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.27</version>
</dependency>
The Search object is coming null at the run-time, causing my application to fail. Is there any compatibility issue between the two jersey versions or am I missing something. Is anyone already using Jersey JAX-RS 2.27 and Java 11 together ?