"java.lang.IllegalStateException - SENDING => HEADERS" when sending an empty HTTP Post to camel-jetty route

Solution In Progress - Updated -

Issue

Trying to send an empty HTTP POST message with no message body to a Camel route that runs a jetty consumer results in "java.lang.IllegalStateException - SENDING => HEADERS" [2]. The empty HTTP Message would look similar to [3] and does not contain a message body.
If the same HTTP POST message contains a message body, no error is raised.
The route runs as a HTTP proxy as documented in [1].

<route>
  <from uri="jetty:http://0.0.0.0:8080/myapp?matchOnUriPrefix=true"/>
  <to uri="jetty:http://realserverhostname:8090/myapp?bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>
</route>

[1] http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html

[2]
13:08:14,978 | ERROR | HttpClient-404   | DefaultErrorHandler              | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | 
Failed delivery for (MessageId: ID-mac-fritz-box-58335-1416744432175-1-11 on 
ExchangeId: ID-mac-fritz-box-58335-1416744432175-1-10). 
Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExchangeException: 
JettyClient failed cause by: SENDING => HEADERS. Exchange[Message: 
[Body is instance of org.apache.camel.StreamCache]]. 
Caused by: [java.lang.IllegalStateException - SENDING => HEADERS]
org.apache.camel.CamelExchangeException: JettyClient failed cause by: SENDING => HEADERS. Exchange[Message: [Body is instance of org.apache.camel.StreamCache]]. Caused by: [java.lang.IllegalStateException - SENDING => HEADERS]
    at org.apache.camel.component.jetty.JettyContentExchange.doTaskCompleted(JettyContentExchange.java:214)[223:org.apache.camel.camel-jetty:2.10.0.redhat-60024]
    at org.apache.camel.component.jetty.JettyContentExchange.onException(JettyContentExchange.java:134)[223:org.apache.camel.camel-jetty:2.10.0.redhat-60024]
    at org.eclipse.jetty.client.HttpExchange$Listener.onException(HttpExchange.java:1108)[83:org.eclipse.jetty.client:7.6.7.v20120910]
    at org.eclipse.jetty.client.AsyncHttpConnection.handle(AsyncHttpConnection.java:166)[83:org.eclipse.jetty.client:7.6.7.v20120910]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627)[81:org.eclipse.jetty.io:7.6.7.v20120910]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51)[81:org.eclipse.jetty.io:7.6.7.v20120910]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)[90:org.eclipse.jetty.util:7.6.7.v20120910]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)[90:org.eclipse.jetty.util:7.6.7.v20120910]
    at java.lang.Thread.run(Thread.java:744)[:1.7.0_45]
Caused by: java.lang.IllegalStateException: SENDING => HEADERS
    at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:370)[83:org.eclipse.jetty.client:7.6.7.v20120910]
    at org.eclipse.jetty.client.AbstractHttpConnection$Handler.startResponse(AbstractHttpConnection.java:298)[83:org.eclipse.jetty.client:7.6.7.v20120910]
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:485)[79:org.eclipse.jetty.http:7.6.7.v20120910]
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)[79:org.eclipse.jetty.http:7.6.7.v20120910]
    at org.eclipse.jetty.client.AsyncHttpConnection.handle(AsyncHttpConnection.java:133)[83:org.eclipse.jetty.client:7.6.7.v20120910]
[3]
POST http://0.0.0.0:8080/myApp HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
Host: 0.0.0.0:9000
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

Environment

  • JBoss Fuse 6.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.