jax-rs

@JsonFilter throws “JsonMappingException: Can not resolve BeanPropertyFilter”

北慕城南 提交于 2020-01-10 01:03:06
问题 Is it possible to selectively determine when the @JsonFilter annotation gets used at runtime? I'm getting JsonMappingException exception (see below) when I don't provide the filter. Background: I learned from a recent StackOverflow post that I can use @JsonFilter to dynamically filter the bean properties getting serialized. This works great. After adding @JsonFilter("apiFilter") to my domain class and with the addition of this code in my jax-rs service (using the CXF implementation), I am

Creating a ResourceConfig that behaves the same way as default Jetty's Jersey registering

試著忘記壹切 提交于 2020-01-09 10:51:47
问题 I have an endpoint with: @POST @Path("/test") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String canaryTest(String JSON) { return JSON; } When I register it in Jetty using Jersey ServletHolder holder = new ServletHolder(new ServletContainer()); everything seems to work fine. But in case I try to specify explictly the default config, it stops working (returning a media type error from the endpoint). Even by just passing a default instance of a

Create Response with Location header in JAX-RS

青春壹個敷衍的年華 提交于 2020-01-09 09:27:46
问题 I have classes auto-generated in NetBeans with RESTful template from entities, with CRUD functions (annotated with POST, GET, PUT, DELETE). I have a problem with create method, which after inserting an entity from the frontend, I would like create to update a response so that my view will automatically (or asynchronously, if that's the right term) reflect the added entity. I came across this (example) line of code but written in C# (of which I know nothing about): HttpContext.Current.Response

Create Response with Location header in JAX-RS

牧云@^-^@ 提交于 2020-01-09 09:27:44
问题 I have classes auto-generated in NetBeans with RESTful template from entities, with CRUD functions (annotated with POST, GET, PUT, DELETE). I have a problem with create method, which after inserting an entity from the frontend, I would like create to update a response so that my view will automatically (or asynchronously, if that's the right term) reflect the added entity. I came across this (example) line of code but written in C# (of which I know nothing about): HttpContext.Current.Response

How to return a partial JSON response using Java?

廉价感情. 提交于 2020-01-09 03:02:26
问题 I'm building a RESTful API and want to provide developers with the option to choose which fields to return in the JSON response. This blog post shows examples of how several API's (Google, Facebook, LinkedIn) allow developers to customize the response. This is referred to as partial response. An example might look like this: /users/123?fields=userId,fullname,title In the example above the API should return the userId, fullName and title fields for User "123". I'm looking for ideas of how to

java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri

烈酒焚心 提交于 2020-01-08 16:55:52
问题 I try to start application but using Tomcat 7 and I've got an exception like this. I think this can be something with Maven dependency , but I'm sure. If some know what is going on please for answer:) Exception: message Servlet execution threw an exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter

expected output is not displaying

让人想犯罪 __ 提交于 2020-01-07 09:26:32
问题 I am learing jersey,below is my program where the output should come like this 8-6-1990 but it is displaying 0-0-0.I dont know the actual reason,can anyone help me Multipleparam.java package com.rest; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; @Path("multi") public class Multipleparam { @GET @Path("{day}/{month}/{year}") public Response getUserHistory(@PathParam("{day}") int day, @PathParam("{month}") int month, @PathParam(

JAX-RS client Jersey Framework required jars

こ雲淡風輕ζ 提交于 2020-01-07 03:34:08
问题 What minimum JAR files of Jersey Framework are needed to run a client? If I include all JAR's it will take 4 MB. 回答1: Jersey 2.x (2.22.1) <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.22.1</version> </dependency> Jersey 1.x (1.19) <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>1.19</version> </dependency> Note: These are just the base client jars. There is no JSON support. For JSON

Application context path at JAX-RS 2.0 resource instance construction

北战南征 提交于 2020-01-06 14:45:15
问题 Is it possible to get the context path for a Java EE 7 application at JAX-RS 2.0 resource class instance construction time (and possibly at static class initialization time, too), or is it only available during requests to endpoints in the resource class? By context path I mean the String that would be returned by a call to a HttpServletRequest#getContextPath() within the Java EE 7 application. I imagine that you probably could have multiple context path aliases for a deployed application. If

Application context path at JAX-RS 2.0 resource instance construction

删除回忆录丶 提交于 2020-01-06 14:45:14
问题 Is it possible to get the context path for a Java EE 7 application at JAX-RS 2.0 resource class instance construction time (and possibly at static class initialization time, too), or is it only available during requests to endpoints in the resource class? By context path I mean the String that would be returned by a call to a HttpServletRequest#getContextPath() within the Java EE 7 application. I imagine that you probably could have multiple context path aliases for a deployed application. If