javax.ws.rs

ExceptionMapper not working consistently in Jersey 2.x & javax

China☆狼群 提交于 2021-02-20 03:49:51
问题 I am using javax and jersey for my api application (exposing api endpoints) I am trying to catch exceptions coming from fasterXml (on put and post calls) by having a Provider which implements ExceptionMapper. My Problem is that on POST or PUT, whenever I am sending wrong attributes names, sometime my mapper catch the exceptions and sometime it doesn't. For example: Running my application once -> everything is working as expected, catching exceptions. Running my application again (restart) ->

ExceptionMapper not working consistently in Jersey 2.x & javax

妖精的绣舞 提交于 2021-02-20 03:49:38
问题 I am using javax and jersey for my api application (exposing api endpoints) I am trying to catch exceptions coming from fasterXml (on put and post calls) by having a Provider which implements ExceptionMapper. My Problem is that on POST or PUT, whenever I am sending wrong attributes names, sometime my mapper catch the exceptions and sometime it doesn't. For example: Running my application once -> everything is working as expected, catching exceptions. Running my application again (restart) ->

Netty websocket and Rest in same Java application

回眸只為那壹抹淺笑 提交于 2021-01-28 12:25:36
问题 I have an exisiting Java application which is exposing REST services. I want to add a new feature in the same application to handle web socket requests (using netty) along with the exisiting REST services. How can I do that without changing my REST services? 回答1: There are two ways to do this without changing your REST service: I would suggest you setup a normal netty websocket server and run it parallel on another port (this can happen in the same application). A more complicated an

Netty websocket and Rest in same Java application

£可爱£侵袭症+ 提交于 2021-01-28 12:22:05
问题 I have an exisiting Java application which is exposing REST services. I want to add a new feature in the same application to handle web socket requests (using netty) along with the exisiting REST services. How can I do that without changing my REST services? 回答1: There are two ways to do this without changing your REST service: I would suggest you setup a normal netty websocket server and run it parallel on another port (this can happen in the same application). A more complicated an

How to get plain XML from javax.ws.rs Entity on client side

梦想与她 提交于 2019-12-11 04:44:49
问题 I have a REST client that creates a XML entity via Entity.entity(myObject, MediaType.APPLICATION_XML_TYPE) . After that, I call webTarget.request().buildPost(... How can I get the request body XML that my client will send to the server? (I need it for debugging reasons.) All I get here is a Entity object. Of course I could serialize it myself with a Marshaller but is this really the same XML the client would send? 回答1: You could have a ClientRequestFilter as following, which is a simplified

How to allow slashes in path param in jax-rs endpoint

萝らか妹 提交于 2019-12-10 23:32:18
问题 I have an endpoint as: @Path("/products") @Produces({ MediaType.APPLICATION_JSON }) public interface Products { @PUT @Path("/{productId}") .... } I have a jax-rs client implemented for this service and have it imported in the another service that I am calling this from. So I am calling the client as below from my second service public String updateProduct(String productId){ .. return client.target(this.getBaseUrl()).path("products/").path(productId).request(MediaType.APPLICATION_JSON_TYPE)