[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RuntimeBeanExpressionException with Camel-Servlet


I found a problem in Camel 2.19 and solved it by simply downgrading to Camel 2.17. Therefore this could be a bug in more current releases. 

Example project: 

- I have reduced my project to a very small example project to illustrate the problem. 
- You can find it attached. It is a Maven/Spring-Boot project. 
- Therefore you can start it with mvn spring-boot:run
- Use any HTTP client to send a get-request to "http://localhost:8080/camel/input"; to get a short text response.
- Send the same request with a header named "fail" and set the value to "true" to get a RuntimeBeanExpressionException as described below. 

Short description of the project:

- Basically I have the following route that consumes from a servlet-endpoint. 
- The choice-block is just to handle the "fail" header and show the two different behaviours. 
- The bodyBean has 1 method with return type String to set the response body
- The bodyBean can throw an Exception (simulate that with the "fail" header)

                .choice().when(PredicateBuilder.or(header(HEADER_NAME_FAIL).isNull(), header(HEADER_NAME_FAIL).isEqualTo("")))
                    .setHeader(HEADER_NAME_FAIL, constant(false)) // fail = false by default

If the bean returns a String, everything is fine. If the bean throws an Exception I get the following: 

org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: null on null due to: org.apache.camel.RuntimeCamelException: java.io.IOException: Stream closed
	at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:228)
	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:127)
	at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:139)
	at org.apache.camel.processor.SetBodyProcessor.process(SetBodyProcessor.java:49)

The project uses Camel 2.19.4, but I also tested with 2.19.5, it didn't work either. When I downgrade to Camel 2.17 this Exception does not occur and I get the "expected" exception thrown by the Bean.


Attachment: camel-bean-showcase.zip
Description: camel-bean-showcase.zip