jersey-2.0

Marshal/Un marshal List objects in Jersey JAX-RS using JAXB

不问归期 提交于 2019-12-09 07:16:17
问题 Good Morning. Today morning when I am going through Jersey Entity providers MessageBodyReader s and MessageBodyWriter s I came across the following problem. I want to write a resource method and client that returns a list of custom objects and media type is application/xml . So I would like to use JAXB (I am new to JAXB). I was able to achieve this by writing my own extended MessageBodyReader and MessageBodyWriter . But I am afraid of the way I am following. Just look at the way I implemented

ParamConverterProvider method return type mismatch

雨燕双飞 提交于 2019-12-09 03:16:59
问题 In the below code snippet I keep receiving the following error in the Provider class. Type mismatch: cannot convert from DemoParamConverter to ParamConverter package com.ofss.shop.application.translators; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import javax.ws.rs.ext.ParamConverter; import javax.ws.rs.ext.Provider; @Provider public class DemoParamConverterProvider { private final DemoParamConverter dpc = new DemoParamConverter(); public <T> ParamConverter<T>

Jersey: @PathParam with commas to List<MyObject>

*爱你&永不变心* 提交于 2019-12-08 17:09:55
问题 I would like to call my Webservice with this pattern : /resource/1,2,3 And in my Class I want to bind my parameters to a List of Object @Path("/resource") public class AppWS { @GET @Path("/{params}") public Response get(@PathParam("params") List<MyObject> params) { return Response.status(200).entity("output").build(); } } With a simple Object: public class MyObject { Integer value; public MyObject(Integer value) { this.value = value; } } nb: If it possible I don't want to create an

Working with configuration properties in Jersey

我的未来我决定 提交于 2019-12-08 11:12:44
问题 I use java/jetty self-hosted server and jersey-2 for java RESTful api. Application has application.properties file with properties. ConfigurationProperties class reads and loads properties file into java.util.Properties class. Jetty server instantiation is done in the following way. // Create and register resources final ResourceConfig resourceConfig = new ApiServiceConfig() .register(new DependencyInjectionBinder()); ServletContextHandler contextHandler = new ServletContextHandler

Dropwizard validate a field only on @POST

≯℡__Kan透↙ 提交于 2019-12-08 08:23:19
问题 I have these read-only fields which needs to be secure, like passwords. Say we have a user object: public class User { @NotEmpty @Size(max = 100) private String name; @NotEmpty private String username; @NotEmpty @Email private String email; private String password; @JsonIgnore public String getPassword() { return password; } @JsonProperty public void setPassword(String password) { this.password = password; } } So, this works nicely; as in I can get/post/put whatever I want, but I will never

Server-Sent Event with Jersey and weblogic

强颜欢笑 提交于 2019-12-08 07:00:48
问题 I am experimenting with server sent event. Am following this link https://jersey.java.net/documentation/latest/user-guide.html#d0e8376. When I make request to the resource representing Server Sent Event, I get 500 Internal server error. According to following error, I have to register the body writer for org.glassfish.jersey.media.sse.EventOutput. But, how to do it? ####<21 Nov, 2013 3:17:28 PM IST> <Error> <com.sun.jersey.spi.container.ContainerResponse> <Laptop1> <AdminServer> <[ACTIVE]

Jersey Test Framework & HK2-Guice bridge

99封情书 提交于 2019-12-08 05:22:44
问题 There are REST web service based on Jersey 2.23.2 & Guice 3.0. To use Guice it is necessary to adjust the hk2-guice bridge (I'm using 2.5.0-b07). Everything works fine until I have tried to test the service using Jersey Test Framework. Can't configure hk2-guice bridge for tests. My test: public class SomeTest extends JerseyTestNg.ContainerPerClassTest { @Override protected TestContainerFactory getTestContainerFactory() throws TestContainerException { return new GrizzlyWebTestContainerFactory(

unable to get all values of json

你。 提交于 2019-12-08 02:21:51
问题 I am trying to return values fetched from database to frontend view using rest webservice but the problem is its returning only the one line(first line) of json values I have json like this: {"jobName":"NASA Scientist","jobPrimarySkill":null,"jobRole":"JOB_ROLE","jobDesignation":"JOB_EXP","jobDescription":"Sample 2","jobSalaryRange":"JOB_POSITIONS","jobExp":"JOB_SAL_RANGE","jobPositions":"JOB_POSTEDBY","jobPostedBy":null} {"jobName":"NASA Scientist","jobPrimarySkill":null,"jobRole":"JOB_ROLE"

GlassFish 4.0 / Jersey 2.0 - NoClassDefFoundError for JsonStructureBodyReader

╄→尐↘猪︶ㄣ 提交于 2019-12-07 18:15:43
问题 I'm using GlassFish 4.0 R89 on my dev system, working with JAX-RS. Simple calls work, so I can get a serialized object, represented in XML. I had to install that on the machine of a guy who will also be involved in the coding process, and I also tried that on my notebook - and I'm getting the same result - a NoClassDefFoundError is thrown for the class JsonStructureBodyReader (although I'm not even using JSON, tried that, the server definitely returns XML with correct headers for the content

Moxy ignore invalid fields in json

不打扰是莪最后的温柔 提交于 2019-12-07 10:08:15
问题 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