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
42
votes
7 answers

Jersey + Jackson JSON date format serialization - how to change the format or use custom JacksonJsonProvider

I am using Jersey + Jackson to provide REST JSON services layer for my application. The problem I have is that the default Date serialization format looks like that: "CreationDate":1292236718456 At first I thought it is a UNIX timestamp... but it…
adrin
  • 3,738
  • 8
  • 40
  • 60
41
votes
3 answers

How to choose between JAX-RS and JAX-WS web services implementation?

In what contexts is it better to use one over the other and why? Thanks!
kgautron
  • 7,915
  • 9
  • 39
  • 60
40
votes
1 answer

Jersey/JAX-RS : How to cascade beans-validation recursively with @Valid automatically?

I am validating my POJOs in a REST resource endpoint in Jersey: public class Resource { @POST public Response post(@NotNull @Valid final POJO pojo) { ... } } public class POJO { @NotNull protected final String name; …
user4460845
40
votes
3 answers

How to retrieve JSON Response from a javax.ws.rs.core.Response response?

I am making a request to an API and getting a response status code of 200. Response of the api includes a json response. import javax.ws.rs.core.Response; Response response = webclient.post(SomeReqString); How can I retrieve the json response as…
goodmayhem
  • 3,364
  • 4
  • 16
  • 17
40
votes
5 answers

JAX-RS @PathParam How to pass a String with slashes, hyphens & equals too

I am new to JAX-RS and I am trying to use Jersey to build a simple RESTful Webservice. I have 2 questions. Please clarify these: I am trying to have my simple webservice like this URL http://localhost:8080/SampleJersey/rest/inchi/InChIName The…
Sashi Kiran Challa
  • 905
  • 1
  • 11
  • 21
40
votes
5 answers

JAX-RS Application on the root context - how can it be done?

I would like to have my JAX-RX Application start at the root context so my URLs will be http://example.com/restfullPath and not http://example.com/rest/restfullPath I switched my Application's annotation from this @ApplicationPath("/rest/*") to…
Eran Medan
  • 44,555
  • 61
  • 184
  • 276
38
votes
1 answer

jaxrs-api VS jsr311-api VS javax.ws.rs-api VS jersey-core VS jaxrs-ri

I have googled around quite a bit still am confused as to what each of the above exactly mean. Here is my understanding of it: jaxrs-api : contains only api. No implementation. But how is it different from JSR311 jsr311-api : JSR311 it is a…
Gadam
  • 2,674
  • 8
  • 37
  • 56
38
votes
3 answers

JAX-RS jersey ExceptionMappers User-Defined Exception

I am new to this, trying to achieve reading some docs but its not working, please bear with me. I have created a UserNotFoundMapper using ExceptionMappers like this: public class UserNotFoundMapper implements ExceptionMapper
WhoAmI
  • 819
  • 4
  • 18
  • 35
38
votes
3 answers

How can I generate WADL for REST services

I have a web application providing more than 30 REST services (using Jersey) to clients. Is it possible to automatically create a WADL document for my application? I need this, so that I can have it configured in SoapUI for testing various scenarios…
basiljames
  • 4,777
  • 4
  • 24
  • 41
37
votes
3 answers

Send redirect from a JAX-RS service

Is it possible to have a JAX-RS web service redirect to another web page? Like as you would do with Servlet response.sendRedirect("http://test/test.html"). The JAX-RS web service should itself redirect. I'm using RESTEasy if that's relevant.
c12
  • 9,557
  • 48
  • 157
  • 253
37
votes
8 answers

MessageBodyReader not found for media type=application/json

I have wrote a JAX-RS server and client both use Jersey. I want to sent a collection of my entities to client and I made this steps: Made entity extends Serializable Wrote a custom provider and extended it to support a collections Copy-paste entity…
user559730
37
votes
4 answers

Can we have more than one @Path annotation for same REST method

Can we have more than one @Path annotation for same REST method i.e. the method executed is the same, but it is executed on accessing more than one URL? E.g.: I want to run the searchNames() method on both http://a/b/c and http://a/b.
Unreal user
  • 1,045
  • 2
  • 9
  • 13
35
votes
1 answer

JAX-RS using exception mappers

I have read that I can create an implementation of javax.ws.rs.ext.ExceptionMapper that will map a thrown application exception to a Response object. I've created a simple example which throws an exception if the phone length is greater than 20…
Jordan Allan
  • 4,408
  • 7
  • 32
  • 35
35
votes
5 answers

AbstractMethodError using UriBuilder on JAX-RS

I am trying to build a REST webservice using an asynchronous response. I have looked around this error on the web, however, none of the solutions have worked for me. I am not sure on how to go about it. This is the code for the REST service, it has…
user471450
35
votes
7 answers

SEVERE: MessageBodyWriter not found for media type=application/json, type=class com.jersey.jaxb.Todo, genericType=class com.jersey.jaxb.Todo

I am trying to create a RESTful web-service and I created one but I am getting a MessageBodyWriter not found for media type=application/json error My Todo class: package com.jersey.jaxb; import javax.xml.bind.annotation.XmlAccessType; import…
Raj Hassani
  • 1,577
  • 1
  • 19
  • 26