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
30
votes
3 answers

How to find out incoming RESTful request's IP using JAX-RS on Heroku?

I'm writing a Java RESTful service hosted on Heroku based on an example -> https://api.heroku.com/myapps/template-java-jaxrs/clone My sample service is: package com.example.services; import com.example.models.Time; import javax.ws.rs.GET; import…
Luke
  • 1,053
  • 2
  • 16
  • 26
29
votes
6 answers

Rest - how get IP address of caller

I am writing a Java Rest Web Service and need the caller's IP Address. I thought I saw this in the cookie once but now I don't see it. Is there a consistent place to get this information? I saw one example of using an "OperationalContext" to get it…
Wanderer
  • 1,583
  • 4
  • 20
  • 36
29
votes
1 answer

DropWizard Bootstrap vs Configuration vs Environment

A typical DropWizard application specifies an Application subclass, and override its initialize method like so: class MyApplication extends Application { static void main(String[] args) { new MyApplication().run(args) …
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
29
votes
1 answer

which init-param to use: jersey.config.server.provider.packages or javax.ws.rs.Application?

I am deploying JAX-RS web services to a Tomcat servlet container. I have seen code examples that use either of the following two methods of indicating the resources in the web.xml file: method 1 - using the `jersey.config.server.provider.packages`…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
29
votes
4 answers

Custom response header Jersey/Java

I am trying to achieve the following. Read a custom header and its value from Request: name: username Now, on response, I would like to return the same header name:value pair in HTTP response. I am using Jersey 2.0 implementation of JAX-RS…
Namenoobie
  • 541
  • 2
  • 8
  • 15
29
votes
3 answers

How do I unit test code which calls the Jersey Client API?

I wrote code which calls the Jersey client API which in turn calls a web service which is out of my control. I do not want my unit test to call the actual web service. What is the best approach for writing a unit test for code which calls the Jersey…
BennyMcBenBen
  • 1,438
  • 2
  • 20
  • 37
29
votes
2 answers

What's the difference between QueryParam and MatrixParam in JAX-RS?

What's the difference between the JAX-RS @QueryParam and @MatrixParam? From the documents.The queryparam and matrixparam both can location one resource in special condition. So what's the use case difference? ps: Queryparam: url ?…
jiafu
  • 6,338
  • 12
  • 49
  • 73
28
votes
10 answers

A message body writer for Java type, class myPackage.B, and MIME media type, application/octet-stream, was not found

I am new at RESTful webservices and was trying to update my @OneToMany relationship from a standalone client application, but I am not able to do that. I am using the Jersey implementation of JAX-RS that ships with Glassfish 3.1.1. I have a class A…
skip
  • 12,193
  • 32
  • 113
  • 153
28
votes
2 answers

What's a JAX-RS implementation?

I have been trying to figure out how to use JAX-RS for quite some time. I started from the very basic concepts and then to gradually understand the annotation styled programming, the meaning of @Path, @Get, @Post, etc. To my understanding, as to…
lixiang
  • 1,941
  • 3
  • 20
  • 25
28
votes
3 answers

NoSuchMethodError on startup in Java Jersey app

I've been getting a very strange error when trying to start a Jersey app on Tomcat. The same code works on other computers. I tried reinstalling tomcat, all my maven dependencies, even Eclipse and Java itself, no luck. It seems like a bad Jersey…
SGr
  • 853
  • 2
  • 9
  • 15
28
votes
1 answer

how to send json object from REST client using javax.ws.rs.client.WebTarget

I have a POJO given below which I want to PUT to the server as JSON or XML. This is what I have done CLIENT: ClientConfig config = new ClientConfig(); Client client = ClientBuilder.newClient(config); WebTarget target =…
user3275095
  • 1,605
  • 4
  • 24
  • 36
28
votes
6 answers

Convert JSON query parameters to objects with JAX-RS

I have a JAX-RS resource, which gets its paramaters as a JSON string like this: http://some.test/aresource?query={"paramA":"value1", "paramB":"value2"} The reason to use JSON here, is that the query object can be quite complex in real use…
deamon
  • 89,107
  • 111
  • 320
  • 448
28
votes
2 answers

Is JAX-RS Client Thread Safe

In Java EE7, the JAX-RS Client API provides a high-level API for accessing any REST resources. According to the documentation, "Clients are heavy-weight objects that manage the client-side communication infrastructure. Initialization as well as…
wen
  • 283
  • 1
  • 3
  • 5
28
votes
1 answer

Spring MVC REST is not JAX-RS compliant. Does it matter?

I've had good experience with Spring MVC REST with a couple of solid projects delivered. My question is about JAX-RS compliance. Does it matter because Spring is here to stay and I don't foresee (nor have a reason to) having to move away from…
user6123723
  • 10,546
  • 18
  • 67
  • 109
28
votes
2 answers

How to get POST parameter in JAX-RS method?

I am developing RESTful services with Jersey and it works great with GET methods. But I can only get null parameters using the POST method. Here is the sample code from my project. HTML
user1573269
  • 363
  • 1
  • 4
  • 9