Hi Daniel, Thanks very much for the detailed report.
I've been able to reproduce the issue, add a test case and fix the underlying problem (in both 2.1 and 2.2 branches). Actually, it was a serious issue beyond the JAX-RS extension itself as the internal connector wasn't restoring the current Response, Application, Context and Virtual Host (thread local variables) when writing the outbound entities. Thanks, Jerome -- http://restlet.com http://twitter.com/#!/jlouvel 2013/1/31 Daniel Halperin <[email protected]> > Hi everyone, > > I'm just getting started with RESTlet (v.2.1.1, with > org.restlet.jee.ext.jackson & jee.ext.jaxrs), so I may be doing something > very wrong. However, basic things work well for me. For instance, if I > return POJOs from a function annotated with > @Produces(MediaType.APPLICATION_JSON), they seem to be returned properly. > > Right now, I'm experimenting with implementing different handlers for > different Content-Types. I started with the simplest possible: echo JSON > input (converted to String) back as JSON: > > /** > * Class that handles queries. > * > * @author dhalperi > */ > @Path("/query") > public final class QueryResource { > /** > * For now, simply echoes back its input. > * > * @param input the payload of the POST request itself. > * @return the payload. > */ > @POST > @Produces(MediaType.APPLICATION_JSON) > @Consumes(MediaType.APPLICATION_JSON) > public String postNewQuery(final String input) { > return input; > } > } > > If I access this resource with an invalid Content-Type (curl -i -XPOST > localhost:8753/query -d "hi"), the curl process hangs and it looks like > RESTlet experiences an internal exception deep in its code: > > Exception in thread "Restlet-PipedWritableChannel" > java.lang.NullPointerException > at > org.restlet.ext.jaxrs.internal.provider.StringProvider.getCurrentResponseEntityCharset(StringProvider.java:98) > at > org.restlet.ext.jaxrs.internal.provider.StringProvider.writeTo(StringProvider.java:178) > at > org.restlet.ext.jaxrs.internal.provider.StringProvider.writeTo(StringProvider.java:63) > at > org.restlet.ext.jaxrs.internal.wrappers.provider.SingletonProvider.writeTo(SingletonProvider.java:350) > at > org.restlet.ext.jaxrs.internal.util.JaxRsOutputRepresentation.write(JaxRsOutputRepresentation.java:112) > at > org.restlet.representation.StreamRepresentation.write(StreamRepresentation.java:76) > at org.restlet.engine.io.NioUtils$1.run(NioUtils.java:210) > at java.lang.Thread.run(Thread.java:722) > > Google has literally no hits for 'Restlet-PipedWritableChannel'---so I > came here. :) > > Note that if I use the expected Content-type, it works fine: curl -i > -XPOST localhost:8753/query -H "Content-type: application/json" -d "hi" > > INFO: 2013-01-30 18:15:30 127.0.0.1 - - 8753 POST /query - 200 2 2 10 > http://localhost:8753 curl/7.28.1 - > > What suggestions does the group have for me? > > Thanks! > Dan > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3048268

