camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dudgeon <tdudgeon...@gmail.com>
Subject Re: REST DSL conundrum
Date Mon, 22 Jun 2015 18:15:53 GMT
No, it wasn't that (though I've been caught be that in the past).
It turned out that its something strange with the result needing to be 
set to the body of the Out message, not the In message.
Not totally sure about it, but I have something that works now.

Tim

On 22/06/2015 18:21, Claus Ibsen wrote:
> Hi
>
> If it works without the log, then see this
> http://camel.apache.org/why-is-my-message-body-empty.html
>
> On Mon, Jun 22, 2015 at 7:18 PM, Tim Dudgeon <tdudgeon.ml@gmail.com> wrote:
>> I'm struggling with a REST DSL. It handles a POST request for a file upload,
>> so the request body is binary type, and the response is JSON describing the
>> result. The container is Jetty.
>>
>> My DSL looks like this:
>>
>> rest("/rest/v1/datasets")
>> .post().description("Upload file to create new dataset")
>> .bindingMode(RestBindingMode.off)
>> .produces("application/json")
>> .route()
>> .to("direct:process_the_body")          // this processed the body and
>> returns a result object
>> .marshal().json(JsonLibrary.Jackson) // which here is converted to JSON
>> .log("marshal complete. JSON is ${body}")
>> .endRest()
>>
>> Its all working fine, and the JSON gets marshalled correctly (the log()
>> statement
>> By the request fails with this error:
>>
>> [qtp562561015-19] INFO route2 - marshal complete. JSON is
>> {"id":13,"name":"big_bad","size":null,"metadata":{"type":"ITEM","className":"java.util.stream.ReferencePipeline$Head","size":1},"created":1434992702164,"updated":1434992702164,"loid":333226}
>> [qtp562561015-19] WARN org.eclipse.jetty.server.AbstractHttpConnection -
>> header full: java.lang.RuntimeException: Header>6144
>> [qtp562561015-19] ERROR
>> org.apache.camel.component.jetty.CamelContinuationServlet - Error processing
>> request
>> HttpException(500,null,null)
>> at
>> org.eclipse.jetty.server.AbstractHttpConnection.commitResponse(AbstractHttpConnection.java:645)
>> at
>> org.eclipse.jetty.server.AbstractHttpConnection$Output.flush(AbstractHttpConnection.java:1122)
>> at org.apache.camel.util.IOHelper.copy(IOHelper.java:201)
>> at
>> org.apache.camel.component.http.DefaultHttpBinding.copyStream(DefaultHttpBinding.java:318)
>> at
>> org.apache.camel.component.http.DefaultHttpBinding.doWriteDirectResponse(DefaultHttpBinding.java:378)
>> at
>> org.apache.camel.component.http.DefaultHttpBinding.doWriteResponse(DefaultHttpBinding.java:299)
>> at
>> org.apache.camel.component.http.DefaultHttpBinding.writeResponse(DefaultHttpBinding.java:231)
>> at
>> org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:198)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
>> at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
>> at
>> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)
>> at
>> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
>> at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
>> at
>> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
>> at
>> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>> at
>> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>> at org.eclipse.jetty.server.Server.handleAsync(Server.java:410)
>> at
>> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:519)
>> at
>> org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
>> at
>> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
>> at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:651)
>> at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
>> at
>> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
>> at
>> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
>> at
>> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
>> at
>> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>> at
>> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>> at java.lang.Thread.run(Thread.java:745)
>> [qtp562561015-19] WARN org.eclipse.jetty.server.Response - Committed before
>> 500 null
>> [qtp562561015-19] WARN org.eclipse.jetty.server.AbstractHttpConnection -
>> /rest/v1/datasets
>> java.lang.IllegalStateException: Committed
>> at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1130)
>> at org.eclipse.jetty.server.Response.sendError(Response.java:317)
>> at
>> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1095)
>> at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
>> at
>> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
>> at
>> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>> at
>> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>> at org.eclipse.jetty.server.Server.handleAsync(Server.java:410)
>> at
>> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:519)
>> at
>> org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
>> at
>> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
>> at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:651)
>> at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
>> at
>> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
>> at
>> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
>> at
>> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
>> at
>> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>> at
>> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>> at java.lang.Thread.run(Thread.java:745)
>>
>> Any ideas what's wrong?
>>
>> Tim
>>
>
>


Mime
View raw message