jersey-2.0

@DefaultValue in JAX-RS for dates: now() and MAX

微笑、不失礼 提交于 2019-12-06 08:50:56
I have a query parameter as following: @GET public Response myFunction(@QueryParam("start") final LocalDate start, @QueryParam("end") final LocalDate end) { ... } For this, I created a ParamConverter<LocalDate> which converts a string to a date, and vice versa. Now I want to use @DefaultValue annotation to declare a default value. I have two special default values: today (for start ) the maximum value/infinity (for end ) Is it possible to use the @DefaultValue annotation for this? How? Yes, @DefaultValue value can be used in this situation: @GET public Response foo(@QueryParam("start")

Access HttpServletRequest using @Context annotaion in business layer

雨燕双飞 提交于 2019-12-06 07:45:00
I am able to access HttpServletRequest by using @Context annotation in my rest service. But unable to access the same in repository class.I do not want to pass the request form MyService to MyRespository while calling methods. @Path("/someUrl") public MyService{ @Context private HttpServletRequest request; @Get public void someMethod() { myRepository.someMethod(); } } But same annotation not working for my Repository class @Repository public MyRepository { @Context private HttpServletRequest request; public void someMethod() { //need request here } } it injection null request. Not sure why

Custom MOXyJsonProvider in Jersey 2 not working?

前提是你 提交于 2019-12-06 04:13:26
问题 I was reading over the answer for Moxy ignore invalid fields in json and the approach matched something I'm trying to do, so I decided to give it a shot.. I created a feature to disable the default ConfigurableMoxyJsonProvider; @Provider public class JsonFeature implements Feature { @Override public boolean configure(final FeatureContext context) { final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + '.' + context.getConfiguration().getRuntimeType().name().toLowerCase();

JERSEY : Error Trace : java.lang.IllegalStateException: Entity input stream has already been closed

时光毁灭记忆、已成空白 提交于 2019-12-06 04:06:38
I am working with Jersey 2.x. Following is my controller @GET @Path("{id}") @Produces("application/json") public Response getUser(@PathParam("id") int userId, @Context ContainerRequestContext containerRequestContext) { ContainerRequestContext requestContext = logRequest(containerRequestContext); //To further operations using requestContext } Following is my method inside the same controller class to record request private ContainerRequestContext logRequest(ContainerRequestContext requestContext) { JSONObject requestData = new JSONObject(); try { Map bm = null; ContainerRequest cr =

jersey ws 2.0 @suspended AsyncResponse, what does it do?

孤者浪人 提交于 2019-12-06 04:02:59
问题 I am analyzing some jersey 2.0 code and i have a question on how the following method works: @Stateless @Path("/mycoolstuff") public class MyEjbResource { … @GET @Asynchronous //does this mean the method executes on child thread ? public void longRunningOperation(@Suspended AsyncResponse ar) { final String result = executeLongRunningOperation(); ar.resume(result); } private String executeLongRunningOperation() { … } } Lets say im at a web browser and i type in www.mysite/mycoolstuff this will

jersey 2.3.1 and spring integration compatibility issues

我是研究僧i 提交于 2019-12-06 01:49:47
问题 I am trying to create restful service project setup which will use jersey and spring. i downloaded initially jersey1.8 dependent jars also i got jersey-spring-1.8 and i used com.sun.jersey.spi.spring.container.servlet.SpringServlet as jersey servlet and this setup worked well without any issues. Now i was asked to use latest jersey version that is jersey2.3.1, so i downloaded jersey2.3.1 dependent jars like (jersey-container-servlet-core-2.3.1,jersey-container-servlet-2.3.1 etc). Now the

GlassFish 4.0 / Jersey 2.0 - NoClassDefFoundError for JsonStructureBodyReader

旧街凉风 提交于 2019-12-05 23:11:46
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-type). I thought I might have imported a project incorrectly, but after a comparison of the files in

Cannot inject HttpServletRequest in ContainerRequestFilter via @Context jersey2.x and weblogic 12.1.3

与世无争的帅哥 提交于 2019-12-05 20:12:14
问题 I was not able to inject HttpServletRequest in ContainerRequestFilter via @Context in Jersey 2.22.1 using weblogic 12.1.3. I researched several places that this issue exists and in many places I see that it is fixed in Jersey 2.4, but I am still seeing this issue. My implementation and code is attached. Please let me know if I am missing anything. AuthFilter @Provider @Priority(Priorities.AUTHENTICATION) public class AuthFilter implements ContainerRequestFilter { @Context HttpServletRequest

Getting MessageBodyWriter not found for media type=application/json

风流意气都作罢 提交于 2019-12-05 19:50:00
I've tried everything...can't figure out why I'm getting this exception. What's interesting is that in my IDE (Intellij) everything works without a hitch. Can't figure this out...giving up. Do any of you have any suggestions? dependencies { compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.10.27' compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.7' compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2' compile group: 'ch.qos.logback', name: 'logback-core', version: '1.1.2' compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json

How do I get a reference to the Jackson Object Mapper in a jersey2 / hk2 application

谁说胖子不能爱 提交于 2019-12-05 19:21:46
问题 I have a jersey2 application configured for JSON support via Jackson, adding <dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> <version>${jersey.version}</version> </dependency> in the POM file and public MyApplication() { ... register(JacksonFeature.class) ... } in my application. Everything works, my resources get deserialized POJOs as arguments @POST @Consumes(MediaType.APPLICATION_JSON) public void blah(MyPojo p) { ... } Now one