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(); }

Migrate Jersey project to use Java 10 results in java.lang.IllegalArgumentException at jersey.repackaged.org.objectweb.asm.ClassReader.

tl;dr To use Java 10, switch to Jersey 2.27 (which is the latest as of this date (10/5/18)). java.lang.IllegalArgumentException at jersey.repackaged.org.objectweb.asm.ClassReader.<init> Jersey repackages asm and puts these class files into the jersey-server jar. Just digging through the jar in my IDE, I looked at the ClassReader constructor (that’s what <init> means) to see where IllegalArgumentException … Read more

java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri

You’re using both Jersey 1 & 2 (Jersey 1 is an explicit dependency, Jersey 2 is a transitive dependency of jersey-test-framework-provider-jdk-http) and that’s not possible – so the classloader is picking up the wrong URIBuilder class. The Jersey dependencies in group com.sun.jersey are all Jersey version 1. Jersey version 2 uses the group org.glassfish.jersey. You … Read more

JAX-RS Jersey 2.10 support in Websphere 8

You need to do the following steps: Disable built in JAX-RS via JVM property com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine=true see description here. You can set this property via web admin console in Servers > WebSphere Application Servers > yourServerName. Then in Server Infrastructure section Java and Process Management > Process definition > Java Virtual Machine > Custom properties. Create … Read more

What exactly is the ResourceConfig class in Jersey 2?

Standard JAX-RS uses an Application as its configuration class. ResourceConfig extends Application. There are three main ways (in a servlet container) to configure Jersey (JAX-RS): With only web.xml With both web.xml and an Application/ResourceConfig class With only an Application/ResourceConfig class annotated with @ApplicationPath. With only web.xml It is possible to configure the application in a … Read more