jersey-2.0

Moxy ignore invalid fields in json

大城市里の小女人 提交于 2019-12-05 16:09:10
When I send this request: {"invalidField": "value", "date": "value"} to my rest service: @PUT @Consumes("application/json") public void putJson(Test content) { System.out.println(content.toString()); } I expected to get an exception because: There is no invalidField in my domain model. Date format is not valid. But really I get test object with null values. My dmain model is: public class Test { private String name; private Date date; //getters and setters here } I think this is not a valid behavior. How can I fix that? Thanks for help. Solution: As Blaise Doughan said, it is required to

JAX-RS in Dropwizard: Handling async call with immediate response

ぐ巨炮叔叔 提交于 2019-12-05 15:48:12
I have a Resource Class , with a @ManagedAsync method Class which looks like this: @Path("my-resource") public class MyResource extends BaseResource{ private DatumDAO datumDAO; public MyResource(DatumDAO datumDAO){ this.datumDAO = datumDAO; } public void cleanDatum(Datum datum){ //time taking operations } @GET @ManagedAsync @Path("/cleanup/{from}/{till}/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @UnitOfWork public void cleanupDirtyData(@Suspended final AsyncResponse asyncResponse, @PathParam("from") DateTimeParam from, @PathParam("till") DateTimeParam till)

Specify Custom Application Context

南笙酒味 提交于 2019-12-05 14:51:21
问题 We are migrating some of our data services from Jersey 1.x using jersey-spring to Jersey 2.x using jersey-spring3. We have a few test classes that inherit from JerseyTest. Some of these classes use custom applicationContext.xml files that are not specified in the web.xml file. In Jersey 1.x the test classes that extended JerseyTest could call the super constructor with a WebappDescriptor.Builder to which a context parameter could be passed to set or override the application context path. E.g.

AbstractMethodError on UriBuilder when upgrading Jersey client 1.x to 2.x

醉酒当歌 提交于 2019-12-05 14:21:15
We're in the process to upgrade our Web application (running on Tomcat7) from Jersey 1.7 to Jersey 2.4.1. I managed to have the server-side working now, but the JUnit tests which are using jersey-client are throwing the AbstractMethodError: java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder; at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119) at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:72) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:180) at org.glassfish.jersey.client

JAX-RS 2.0 WebSphere 8.5 without isolated shared library

橙三吉。 提交于 2019-12-05 13:53:18
I am using Jersey 2 to implement JAR-RS 2.0 in an IBM WebSphere 8.5 environment. After reading this post JAX-RS Jersey 2.10 support in Websphere 8 I managed to get this working. However, is it possible to bundle the JAX-RS Jars within the WAR and deploy the application without the need to create an isolated shared library? If this is not possible, can someone please explain why this is the case? I understand the deployment time advantage of having the Jars in a library, but I would prefer to build the entire application including dependencies into a single WAR. -- EDIT -- It appears that you

Jersey 2 + HK2 - automatic binding of classess

吃可爱长大的小学妹 提交于 2019-12-05 11:35:42
Continuation of topic Jersey 2 + HK2 - @ApplicationScoped not working . I already know, how to bind classes in order to @Inject them properly. Do you have any ideas, how to automize this process? Putting every single service in bind statements seems like very bad smell in my application. After using Google's Guice for a number of years, I am accustomed to the availability of a Just-In-Time binder, allowing the injection of arbitrary types without requiring any upfront configuration. I too found the idea of having to explicitly bind every service to be a bad code smell. I'm also not crazy about

WARNING: The (sub)resource method contains empty path annotation

二次信任 提交于 2019-12-05 09:19:00
问题 I have configured rest path like "/v1/" and the endpoint configured in servlet like '/test/'. Now I removed the "/v1" from the java class "Test". org.glassfish.jersey.internal.Errors logErrors WARNING: The following warnings have been detected: WARNING: The (sub)resource method test in com.abc.services.Test contains empty path annotation. I got the above warning after make this change. How to handle this warning? And I want this "/v1" removing changes for across 10 rest paths. So anyone help

JAX-RS Response Object displaying Object fields as NULL values

二次信任 提交于 2019-12-05 07:51:18
First time implementing JAX-RS Client API in an application and I am having some small problems when it comes to storing the response data, which is returned as JSON as a Java BEAN. Refer to the following code snippets below which demonstrate how I have implemented it thus far. object = client.target(uri).request().post(Entity.entity(requestObject, APPLICATION_JSON), Object.class); Essentially, I would like to store the returned JSON response from the web service into my Java BEAN, which in this scenario is named object . requestObject is obviously the data which I am sending through to the

How to change the Validation Error behaviour for Dropwizard?

谁说胖子不能爱 提交于 2019-12-05 05:17:03
问题 In Dropwizard I use @Valid annotations for my resource methods: public class Address { @NotNull String street ... } @Path("/address") @Produces(MediaType.APPLICATION_JSON) public class AddressResource { @POST public MyResponse addAddress(@Valid Address address) { if (address == null) { throw new WebApplicationException("address was null"); } ... } } On application start I register a custom WebApplicationExceptionMapper which handles WebApplicationExceptions . Thus, for addresses with the

What is the Jersey 2.0 equivalent of GZIPContentEncodingFilter

我的梦境 提交于 2019-12-05 03:03:29
I am in the progress to migrate a Jerset 1.x client project to Jersey 2.0. I found that GZIPContentEncodingFilter does not exist any longer. Is there something similar? I stumbled over GZIPEncoder but am not sure how to plug it in. In Jersey 1.17 I use: WebResource r = ... r.register(new GZIPContentEncodingFilter()); In Jersey 2.0 I search for somethink like: WebTarget r = ... r.register(new GZIPContentEncodingFilter()); Use WebTarget r = ... r.register(GZIPEncoder.class); Most of details can be obtained from Jersey's own unit tests. So to allow responses to be compressed using GZip or Deflate