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
4
votes
1 answer

How can I enable CDI with Jersey Test Framework?

I found How can I inject a data source dependency into a RESTful web service with Jersey (Test Framework)? but I think I'm gonna ask a little bit different question. This is a follow-up question of @PostConstruct of abstract ancestors are not…
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
4
votes
2 answers

@PostConstruct of abstract ancestors are not invoked

I'm writing a JAX-RS library (not an application). I have: abstract class A { @PostConstruct private void constructed_a() {} // not invoked @Inject private Some some; } public abstract class B extends A { @PostConstruct …
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
4
votes
1 answer

How can I bind a factory to a annotation-qualified injection point?

I asked and got an answer how to bind a named injection point. And I don't know how to bind a factory to a qualified injection point. class SomeResource { @Inject @Some // is a @Qualifier, of course. private MyType qualified; } I…
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
4
votes
2 answers

How to use Jersey as JAX-RS implementation without web.xml?

I have read that from JavaEE 6 web.xml is optional. So without web.xml, how can I tell the application server to use Jersey as the implementation for JAX-RS specification?
DesirePRG
  • 6,122
  • 15
  • 69
  • 114
4
votes
2 answers

Loading properties file in a Java Jersey RESTful web app, to persist throughout the app?

I'm currently building a RESTful API using Jersey. So far, all has been going well, however, all of the configuration entries have been hard coded in. (i.e. Database Host, Database Username, etc...). I'd like to be able to setup a config.properties…
carbon_ghost
  • 1,114
  • 5
  • 18
  • 40
4
votes
0 answers

Jersey Server Sent Events not working with Accept-Encoding gzip

I am using Jersey 2.17 for SSE - I have the demo working per the docs: https://jersey.java.net/documentation/latest/sse.html. In my tests, it works fine with simple curl requests (curl --verbose "localhost:9000/api/broadcast"), but if I add -H…
Kevin
  • 11,521
  • 22
  • 81
  • 103
4
votes
1 answer

jersey webservice not returning jsonp

I am trying to create a webservice that will return jsonp. At the moment it is only returning json Here is my code: @Path("/jsonp") public class JsonpWebservice { @GET @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) …
Damien
  • 4,081
  • 12
  • 75
  • 126
4
votes
1 answer

jersey2 Unit testing,HttpServletRequest is null

Ask everybody to help? jersey Bug connection: [1]: https://java.net/jira/browse/JERSEY-2412 The servlet request, response and context not injected into the class when I using test provider (tested jetty and grizzly2). I using packages annotation…
jack
  • 113
  • 2
  • 9
4
votes
1 answer

How to return a JSON object from a HashMap with Moxy and Jersey

I am using Jersey 2.17 with Moxy and I have functions like : @Produces(APPLICATION_JSON) @Restricted public List getFriends( @PathParam("user") String user ) { return userDAO.getFriends(user); } User.preferences is a HashMap. It…
arisalexis
  • 2,079
  • 2
  • 21
  • 42
4
votes
1 answer

Multi tenancy with Guice Custom Scopes and Jersey

I am in the process of developing a multi tenancy application with Jersey using Guice for DI (I also use Dropwizard but I don't think it matters here). One thing that bothers me is the fact that some kind of tenancy_id is all over the place in my…
scho
  • 323
  • 1
  • 14
4
votes
2 answers

is it safe to use string hashcode as etag

Given a certain input parameter, for a rest api i want to use the hashcode as etag. What is the probability that the json response has changed and the hashcode will be the same? Alternatively is there a better way to do this? @GET public…
David Michael Gang
  • 7,107
  • 8
  • 53
  • 98
4
votes
2 answers

Options for custom serializers / deserializers with Dropwizard?

What's a good way to have custom (de)serializers that can be registered externally with dropwizard? I was having problems with (de)serializing a composite object. I tried using @JsonUnwrapped to get the JSON I wanted, but had problems with it for…
neuronotic
  • 487
  • 7
  • 18
4
votes
3 answers

415 Status when trying to send FormData() in Jax-RS jersey

I'm trying to send files which is appended to FormData using jquery ajax. After referring some of mozilla and IBM's documents, I've came up with following. ajax code: var sessionId = $.cookie("referenceId"); var myFormData = { sessionId: sessionId, …
The Coder
  • 2,562
  • 5
  • 33
  • 62
4
votes
2 answers

Equivalent of Spring MVC @ResponseStatus(HttpStatus.CREATED) in Jersey?

What's the Jersey equivalent of this Spring MVC code? I need the response to return 201 along with the resource URL, following successful POST: @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) Widget…
raffian
  • 31,267
  • 26
  • 103
  • 174
4
votes
1 answer

Jersey (javax) REST MissingAnnotationException

I have an HTML form with several fields and a file upload. On the Java side, I'm receiving the form as follows, and it works: @Component("org.phenotips.metabolites.FileUploaderResource") @Path("/metabolites") public class FileUploaderResource…
Anton
  • 2,282
  • 26
  • 43