Questions tagged [jax-rs]

JAX-RS: Java API for RESTful Web Services. It is an API that provides support in creating web services according to the REST architectural style.

JAX-RS: API for RESTful Web Services is an API that provides support in creating web services according to the architectural style. JAX-RS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints. From version 1.1 on, JAX-RS is an official part of Java EE.

The home for the JAX-RS JSRs is on Java.net.

JAX-RS is implemented by the following frameworks:

Resources:

7676 questions
75
votes
4 answers

How to choose between Jersey, Apache Wink and JBoss RESTEasy?

I just heard about Apache Wink, and I was wondering what differences it had compared to Jersey or JBoss RESTEasy. What can be done in one that the other two can't? We've been using Jersey for some of our internal projects mostly for it's…
Nick Klauer
  • 5,893
  • 5
  • 42
  • 68
73
votes
7 answers

What is the difference between @PathParam and @PathVariable

To my knowledge both serves the same purpose. Except the fact that @PathVariable is from Spring MVC and @PathParam is from JAX-RS. Any insights on this?
suresh
  • 943
  • 2
  • 8
  • 22
73
votes
7 answers

Inject an EJB into JAX-RS (RESTful service)

I'm trying to inject a Stateless EJB into my JAX-RS webservice via annotations. Unfortunately the EJB is just null and I get a NullPointerException when I try to use it. @Path("book") public class BookResource { @EJB private BookEJB…
Zeck
  • 6,433
  • 21
  • 71
  • 111
71
votes
9 answers

How to combine websockets and http to create a REST API that keeps data up to date?

I am thinking about buildning a REST API with both websockets and http where I use websockets to tell the client that new data is available or provide the new data to the client directly. Here are some different ideas of how it could work: ws =…
David Berg
  • 1,958
  • 1
  • 21
  • 37
68
votes
11 answers

javax.xml.bind.JAXBException: Class *** nor any of its super class is known to this context

I'm trying to pass a object via REST web service. Following are my classes explains the functionality that I need using some example codes. Rest Web Service Class…
Shanaka
  • 1,670
  • 3
  • 21
  • 42
67
votes
5 answers

Get ServletContext in JAX-RS resource

I'm playing around with JAX-RS, deploying on Tomcat. It's basically: @Path("/hello") @Produces({"text/plain"}) public class Hellohandler { @GET public String hello() { return "Hello World"; } } Is there any way I can get hold…
leeeroy
  • 11,216
  • 17
  • 52
  • 54
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
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
62
votes
7 answers

Could not serialize object cause of HibernateProxy

I am getting the following error response from the server. HTTP Status 500 - type Exception report message descriptionThe server encountered an internal error () that prevented it from fulfilling this…
Andreas
  • 2,450
  • 1
  • 18
  • 20
58
votes
4 answers

CXF JAXRS - How do I pass Date as QueryParam

I have a service defined as follows. public String getData(@QueryParam("date") Date date) I'm trying to pass a java.util.Date to it from my client (which is jaxrs:client of CXF, not a generic HTTP client or browser). My service receives the date as…
domino
  • 683
  • 2
  • 7
  • 10
56
votes
6 answers

A message body writer for Java class not found

I am new to using JAX-RS and wrote a sample application that outputs a json object. but I am getting an exception. Here is my code: @Path("/hello") public class HelloWorldService { @GET @Path("/query/{artist_id}") …
user1730789
  • 5,157
  • 8
  • 36
  • 57
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
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
54
votes
4 answers

JAX-RS: Multiple paths

Is it possible to do something like that? import javax.ws.rs.GET; import javax.ws.rs.Path; public class xxx { @GET @Path(value = "path1") public Response m1() { ... } @GET @Path(value = "path2") public Response m1() { …
terry207
  • 725
  • 3
  • 7
  • 9
54
votes
7 answers

How to set the charset with JAX-RS?

How can I set the charset with JAX-RS? I've tried @Produces("text/html; charset=UTF-8") but that was ignored and only text/html was send with the HTTP header. I want to set the charset within a MessageBodyWriter, but don't want to extract the media…
deamon
  • 89,107
  • 111
  • 320
  • 448