I have the following global onException clause in my RouteBuilder configure method:
onException(BadHeaderException.class) .handled(true) .transform(constant("Bad API request: " + exceptionMessage())) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400)) The route is as follows: from(String.format("jetty://http://0.0.0.0:%d%s",port, KEEP_ALIVE_URI)) .process(new MyRequiredHeaderProcessor()) .log("My API called") .setBody(simple(KEEP_ALIVE_SUCCESS_MESSAGE)); and MyRequiredHeaderProcessor may throw BadHeaderException: class MyRequiredHeaderProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { final Object myHeader = exchange.getIn().getHeader("MyRequiredHeader"); if (myHeader == null) { throw new BadHeaderException ("Missing header"); } if (!myHeader .equals(someValue)) { throw new BadHeaderException("Incorrect header value"); } } } When I call the jetty URL without the required header, the request is rejected with error code 400 - as expected - BUT the error message is: Bad API request: simple{${exception.message}} Shouldn't exceptionMessage() return the text I set in MyRequiredHeaderProcessor?