Questions tagged [jersey]

Jersey is the open source, production quality, JAX-RS (JSR 311, JSR 339) Reference Implementation for building RESTful Web services.

Jersey is an open source framework for developing RESTful web services in Java and the production-ready reference implementation for JAX-RS 1.1 (JSR-311) and JAX-RS 2.0 (JSR-339). It is included in GlassFish open source application server and WebLogic application server from Oracle, and can be used with other web servers including the lightweight HTTP server included in JDK.

10403 questions
69
votes
5 answers

How to get full REST request body using Jersey?

How can one get the full HTTP REST request body for a POST request using Jersey? In our case the data will be XML. Size would vary from 1K to 1MB. The docs seem to indicate you should use MessageBodyReader but I can't see any examples.
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
64
votes
8 answers

Staying DRY with JAX-RS

I'm trying to minimize repeated code for a number of JAX-RS resource handlers, all of which require a few of the same path and query parameters. The basic url template for each resource looks like this: /{id}/resourceName and each resource has…
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
64
votes
12 answers

MULTIPART_FORM_DATA: No injection source found for a parameter of type public javax.ws.rs.core.Response

I am using Jersey based restful Service implementation strategy to build a service which will be used to upload files. My service class name is : UploadFileService.java (See Code below) package com.jerser.service; import java.io.File; import…
Swarup Saha
  • 895
  • 2
  • 11
  • 23
64
votes
11 answers

Practical advice on using Jersey and Guice for RESTful service

From what I can find online, the state of the art for Guice + Jersey integration has stagnated since 2008 when it appears both teams reached an impasse. The crux of the issue is that JAX-RS annotations perform field and method injection and this…
user23987
64
votes
7 answers

How to automate documentation of a REST API (Jersey Implementation)

I have written a pretty extensive REST API using Java Jersey (and JAXB). I have also written the documentation using a Wiki, but its been a totally manual process, which is very error-prone, especially when we need to make modifications, people tend…
Alan Mc Kernan
  • 763
  • 1
  • 6
  • 7
61
votes
4 answers

How to return a PNG image from Jersey REST service method to the browser

I have a web server running with Jersey REST resources up and I wonder how to get an image/png reference for the browsers img tag; after submitting a Form or getting an Ajax response. The image processing code for adding graphics is working, just…
gorn
  • 8,097
  • 5
  • 37
  • 44
59
votes
2 answers

RESTEasy or Jersey?

I have a requirement for RESTFul webservices. It is up to my team to decide whether to go with Jersey or Restlet or RESTEasy or anything else. after omitting other frameworks, we are not able to choose between RESTEasy and Jersey. Since both of them…
Tioma
  • 2,120
  • 9
  • 35
  • 52
59
votes
3 answers

What is the difference between Spring REST service, Jersey REST service and Spring+Jersey solutions?

I want to build a RESTful service/API. I used some framework like play to build it but I want to try other more efficient ways. I heard that Jersey is a common library for building a REST API, and Spring is also a good framework. But I also saw some…
Terry
  • 855
  • 4
  • 12
  • 16
59
votes
6 answers

Using the Jersey client to do a POST operation

In a Java method, I'd like to use a Jersey client object to do a POST operation on a RESTful web service (also written using Jersey) but am not sure how to use the client to send the values that will be used as FormParam's on the server. I'm able…
Jon Onstott
  • 13,499
  • 16
  • 80
  • 133
59
votes
3 answers

How to set the connection and read timeout with Jersey 2.x?

In jersey 1 we had a function setConnectTimeout in the class com.sun.jersey.api.client.Client. In jersey 2 the javax.ws.rs.client.Client class is used where this function is missing. How to set connection timeout and read timeout in jersey 2.x?
David Michael Gang
  • 7,107
  • 8
  • 53
  • 98
56
votes
10 answers

org.glassfish.jersey.servlet.ServletContainer ClassNotFoundException

I have been getting a ClassNotFoundException with org.glassfish.jersey.servlet.ServletContainer but it peculiarly started last night when I tried to start/re-start my Tomcat server (v7) with Eclipse Juno. Not sure what is going on. What's bizarre…
ssankara73
  • 683
  • 1
  • 5
  • 6
55
votes
2 answers

How can I customize serialization of a list of JAXB objects to JSON?

I'm using Jersey to create a REST web service for a server component. The JAXB-annotated object I want to serialize in a list looks like this: @XmlRootElement(name = "distribution") @XmlType(name = "tDistribution", propOrder = { "id",…
Alpha Hydrae
  • 2,891
  • 6
  • 26
  • 24
55
votes
1 answer

Troubles with WADL / generated XSD using Jersey with a contract-first approach

I have been working on a REST web service using Jersey for a few days now, and managed to have all CRUD operations working, with several exchange formats: XML, JSON, Google Protobuf. However I am facing some issues related to automatically generated…
Marc Carré
  • 1,446
  • 13
  • 19
54
votes
6 answers

How do you map multiple query parameters to the fields of a bean on Jersey GET request?

A service class has a @GET operation that accepts multiple parameters. These parameters are passed in as query parameters to the @GET service call. @GET @Path("find") @Produces(MediaType.APPLICATION_XML) public FindResponse find(@QueryParam("prop1")…
onejigtwojig
  • 4,771
  • 9
  • 32
  • 35
52
votes
8 answers

Custom ObjectMapper with Jersey 2.2 and Jackson 2.1

I am struggling with a REST application with Grizzly, Jersey and Jackson, because Jersey ignores my custom ObjectMapper. POM dependencies: org.glassfish.jersey.containers
svenwltr
  • 17,002
  • 12
  • 56
  • 68