I have the following class for REST calls. Before I was using jersey 1.13 on which everything was working fine, now I have upgraded to jersey 2.27, I am getting the following error on any rest call to the given class
WARNING [http-nio-8080-exec-4] org.glassfish.jersey.internal.Errors.logErrors The following warnings have been detected: WARNING: HK2 service reification failed for [com.MyClass] with an exception: MultiException stack 1 of 2 java.lang.IllegalArgumentException: The field field(HttpServletRequest request in com..MyClass) may not be static, final or have an Annotation type
MultiException stack 2 of 2 java.lang.IllegalArgumentException: Errors were discovered while reifying SystemDescriptor( implementation=com.MyClass contracts={com.MyClass} scope=org.glassfish.jersey.process.internal.RequestScoped qualifiers={} descriptorType=CLASS descriptorVisibility=NORMAL metadata= rank=0 loader=null proxiable=null proxyForSameScope=null analysisName=null id=150 locatorId=0 identityHashCode=1270899559 reified=false)
@Path("/myclass") public MyClass{ @Context static HttpServletRequest request; @Context HttpServletResponse response; @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/method1") public Response method1(PostObj postObj) { //implementation } } If I remove static keyword it works fine. But I want request to be kept static only. What is the issue with static keyword here ? How do I fix it ?