jax-rs

Which ReastEasy 4 client dependencies are needed?

穿精又带淫゛_ 提交于 2021-02-11 13:38:56
问题 I've upgraded to ReastEasy 4 on my client, but there are several errors reported depending on the configuration. If I use only resteasy-core-spi and resteasy-client-api , I get Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder If I add resteasy-client , I get instead javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request: javax.ws.rs.ProcessingException: RESTEASY003215: could not find

Runtime exception with jersey - java.lang.AbstractMethodError

泪湿孤枕 提交于 2021-02-10 18:09:04
问题 I am trying to execute a RESTful web service deployed on tomcat using Jersey implementation. Following is the resource class @Path("/rest") public class PatientResource { PatientService patientService; @GET @Path("/patient/{patientId}") @Produces(MediaType.APPLICATION_JSON) public Patient getPatientDetails(@PathParam("patientId") String patientId) { //return patientService.getPatientDetails(patientId); return new PatientService().getPatientDetails(patientId); } @GET @Path("/patients")

Apache CXF default POST request body with Jackson

霸气de小男生 提交于 2021-02-10 06:51:55
问题 In an Apache CXF JAX-RS project I'm working on, I've configured the JSON provider to be Jackson. This generally works, but I'd like the POST request body to always be not null , so that if a client sends a request with an empty body (no JSON {} ), I'd still get a default POJO. E.g. CXF side: @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Path("/foo") public Response postFoo(FooObj foo) { if (foo == null) return Response.ok("No foo"); else return

Apache CXF default POST request body with Jackson

匆匆过客 提交于 2021-02-10 06:51:38
问题 In an Apache CXF JAX-RS project I'm working on, I've configured the JSON provider to be Jackson. This generally works, but I'd like the POST request body to always be not null , so that if a client sends a request with an empty body (no JSON {} ), I'd still get a default POJO. E.g. CXF side: @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Path("/foo") public Response postFoo(FooObj foo) { if (foo == null) return Response.ok("No foo"); else return

Swagger UI doesn't support uploading a file properly for RestEasy

╄→尐↘猪︶ㄣ 提交于 2021-02-08 10:18:33
问题 I use a JAX-RS (RestEasy) along with a Swagger. One of my endpoint can upload a file. Defined way to upload the file (in RestEasy) is to provide a org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput as a parameter. Here is my endpoint: @PUT @Path("/apis/{id}/file") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Registers a file.", code = 201, nickname = "registerFile") @ApiResponses( value = { @ApiResponse(code = 201,

Swagger UI doesn't support uploading a file properly for RestEasy

◇◆丶佛笑我妖孽 提交于 2021-02-08 10:16:34
问题 I use a JAX-RS (RestEasy) along with a Swagger. One of my endpoint can upload a file. Defined way to upload the file (in RestEasy) is to provide a org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput as a parameter. Here is my endpoint: @PUT @Path("/apis/{id}/file") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Registers a file.", code = 201, nickname = "registerFile") @ApiResponses( value = { @ApiResponse(code = 201,

JAX-RS on TomCat always returns 404

隐身守侯 提交于 2021-02-08 09:45:11
问题 I have already looked at many tutorials, but I can't get my simple JAX-RS application to work. Tomcat always returns Error 404. The Application to get Classes: package api; import java.util.HashSet; import java.util.Set; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; @ApplicationPath("/resources") public class MyApplication extends Application { // All request scoped resources and providers @Override public Set<Class<?>> getClasses() { Set<Class<?>> classes = new

Jersey Client: Logging HTTP Redirects

微笑、不失礼 提交于 2021-02-08 08:51:14
问题 I'm using JAX-RS with Jersey. When sending a POST request to an API, I receive a 302 and Jersey follows automatically which results in a 403. In my logging, however, I can only see the failed responses: INFO Rest-Request: POST http://[Jenkins-IP]/job/RestTestingArea/job/testJob/doDelete INFO Rest-Response: POST 403 http://[Jenkins-IP]/job/RestTestingArea/job/testJob/doDelete I have determined that in between request and response there is a redirect because when I turn off redirects, the

Jersey Client: Logging HTTP Redirects

江枫思渺然 提交于 2021-02-08 08:51:11
问题 I'm using JAX-RS with Jersey. When sending a POST request to an API, I receive a 302 and Jersey follows automatically which results in a 403. In my logging, however, I can only see the failed responses: INFO Rest-Request: POST http://[Jenkins-IP]/job/RestTestingArea/job/testJob/doDelete INFO Rest-Response: POST 403 http://[Jenkins-IP]/job/RestTestingArea/job/testJob/doDelete I have determined that in between request and response there is a redirect because when I turn off redirects, the

How to return 400 http status code with @NotNull?

纵饮孤独 提交于 2021-02-08 07:35:28
问题 I have a method that's receive two parameters: id from type Long and name from type String. I need to validate if name is not null with @NotNull from javax.validation.constraints.NotNull and if it is null I need to return the status code http 400. This is my implementation. @GET @Path(URI.route) @Produces(MediaType.APPLICATION_JSON) Response data(@PathParam("id") Long name, @PathParam("name") @NotNull String name) throws Exception; Currently it's return https status code 500. Any idea how I