Practical advice on using Jersey and Guice for RESTful service

Guice integration with Jersey has not stagnated. The opposite is true. Thanks to Paul and his cohorts behind Jersey, the latest 1.7 release contains a special JerseyServletModule class to work with Guice-based servlets. Guice-based constructor injection into JAX-RS resource works! The issue is using JAX-RS annotations such as @QueryParam in the constructor of a JAX-RS … Read more

Ignore self-signed ssl cert using Jersey Client [duplicate]

After some searching and trawling through some old stackoverflow questions I’ve found a solution in a previously asked SO question: Question: Java client certificates over HTTPS/SSL Answer Java client certificates over HTTPS/SSL Here’s the code that I ended up using. // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new … Read more

Java REST implementation: Jersey vs CXF [closed]

I have used both, but for different purposes. CXF worked great to parse a WSDL and create Java POJOs to interact with, so CXF is pretty good for client-side WSDL services. I’m currently using Jersey for server-side implementation and I am impressed with the simplicity of getting up-and-running with RESTful services using Jersey. As Jersey … Read more

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

JAX-RS Implementations Jersey Reference Implementation Usually the most cutting edge Supports true asynchronous (ie web sockets etc…) connections through either Atmosphere or 2.0 version. Has support for Spring and standard injection containers (ie @Inject). Glassfish bundles it. Its much more modular than the other JAX-RS projects. It has a kick ass URI Builder Does not … Read more

Why order of Maven dependencies matter?

The order of dependencies does matter because of how Maven resolves transitive dependencies, starting with version 2.0.9. Excerpt from the documentation: (…) this determines what version of a dependency will be used when multiple versions of an artifact are encountered. (…) You can always guarantee a version by declaring it explicitly in your project’s POM. … Read more

File upload along with other object in Jersey restful web service

You can’t have two Content-Types (well technically that’s what we’re doing below, but they are separated with each part of the multipart, but the main type is multipart). That’s basically what you are expecting with your method. You are expecting mutlipart and json together as the main media type. The Employee data needs to be … Read more

Example of using StreamingOutput as Response entity in Jersey

See if this helps: @GET @Produces(MediaType.TEXT_PLAIN) public Response streamExample() { StreamingOutput stream = new StreamingOutput() { @Override public void write(OutputStream os) throws IOException, WebApplicationException { Writer writer = new BufferedWriter(new OutputStreamWriter(os)); writer.write(“test”); writer.flush(); // <– This is very important. Do not forget. } }; return Response.ok(stream).build(); }