title: Convertation error in bean method execution from simple language expression
body: <p>I want to set exchange header to result of executing bean method, in XML DSL. I found solution in comment for this question - <a href="https://stackoverflow.com/questions/23910858/camel-passing-specific-parameters-from-routes-to-a-generic-bean-method">Camel - Passing specific parameters from routes to a generic bean method</a>, my code is </p>
  
  <p>XML DSL:</p>
  
  <pre><code>&lt;setHeader headerName="dateInterval"&gt;
      &lt;simple&gt;${bean:tableRequestRouteUtil?method=getIntervalForTable(${in.body})}&lt;/simple&gt;
  &lt;/setHeader&gt;
  </code></pre>
  
  <p>the body type at this point is my domain-specific POJO (class webbanking.dto.W4MMsg). Initial type of body is XML String, then it converted to POJO (annotated by JAXB annotations):</p>
  
  <pre><code>&lt;dataFormats&gt;
      &lt;jaxb id="xml" prettyPrint="true"
            contextPath="dto"/&gt;
  &lt;/dataFormats&gt;
  </code></pre>
  
  <p>in blueprint xml
  and </p>
  
  <pre><code>&lt;unmarshal ref="xml" id="xml.unmarshall"/&gt; 
  </code></pre>
  
  <p>in camel route</p>
  
  <p>The getIntervalForTable method of tableRequestRouteUtil bean has parameter of type webbanking.dto.W4MMsg (my pojo) and return type is String. This worked fine, until in input xml does not appear close parenthesis. close parenthesis in input string causes following exception (I omit body of request, it is quite large):</p>
  
  <pre><code>org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: getIntervalForTable('&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;w4MMsg scheme="WAY4Doc" msg_type="Doc" direction="Rq" version="2.0"&gt;...') on tableRequestRouteUtil due to: org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: getIntervalForTable('&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;w4MMsg scheme="WAY4Doc" msg_type="Doc" direction="Rq" version="2.0"&gt;...') on tableRequestRouteUtil due to: org.apache.camel.component.bean.ParameterBindingException: Error during parameter binding on method: public router.domain.HistoryInterval router.TableRequestRouteUtil.getIntervalForTable(webbanking.dto.W4MMsg) at parameter #0 with type: class webbanking.dto.W4MMsg with value type: class java.lang.String and value: &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;w4MMsg scheme="WAY4Doc" msg_type="Doc" direction="Rq" version="2.0"&gt;...
      at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:117)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:132)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.builder.ExpressionBuilder$65.evaluate(ExpressionBuilder.java:1541)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.language.simple.ast.SimpleFunctionStart$1.evaluate(SimpleFunctionStart.java:101)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.builder.SimpleBuilder.evaluate(SimpleBuilder.java:83)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.builder.ProcessorBuilder$4.process(ProcessorBuilder.java:103)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:111)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:111)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:151)[234:org.apache.camel.camel-jetty:2.12.0.redhat-610379]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)[91:org.apache.geronimo.specs.geronimo-servlet_3.0_spec:1.0]
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1496)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:136)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.apache.camel.component.jetty.CamelFilterWrapper.doFilter(CamelFilterWrapper.java:44)[234:org.apache.camel.camel-jetty:2.12.0.redhat-610379]
      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1467)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.Server.handle(Server.java:370)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)[92:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at java.lang.Thread.run(Thread.java:724)[:1.7.0_25]
  Caused by: org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: getIntervalForTable('&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;w4MMsg scheme="WAY4Doc" msg_type="Doc" direction="Rq" version="2.0"&gt;...') on tableRequestRouteUtil due to: org.apache.camel.component.bean.ParameterBindingException: Error during parameter binding on method: public router.domain.HistoryInterval router.TableRequestRouteUtil.getIntervalForTable(webbanking.dto.W4MMsg) at parameter #0 with type: class webbanking.dto.W4MMsg with value type: class java.lang.String and value: &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;w4MMsg scheme="WAY4Doc" msg_type="Doc" direction="Rq" version="2.0"&gt;...
      at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:285)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:114)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      ... 56 more
  Caused by: org.apache.camel.component.bean.ParameterBindingException: Error during parameter binding on method: public router.domain.HistoryInterval router.TableRequestRouteUtil.getIntervalForTable(webbanking.dto.W4MMsg) at parameter #0 with type: class webbanking.dto.W4MMsg with value type: class java.lang.String and value: &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;w4MMsg scheme="WAY4Doc" msg_type="Doc" direction="Rq" version="2.0"&gt;...
      at org.apache.camel.component.bean.MethodInfo$2.evaluateParameterValue(MethodInfo.java:572)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.component.bean.MethodInfo$2.evaluate(MethodInfo.java:472)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.component.bean.MethodInfo.createMethodInvocation(MethodInfo.java:239)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:278)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:180)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:148)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:67)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:189)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:281)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      ... 57 more
  Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: webbanking.dto.W4MMsg with value &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;w4MMsg scheme="WAY4Doc" msg_type="Doc" direction="Rq" version="2.0"&gt;...
      at org.apache.camel.converter.jaxb.FallbackTypeConverter.convertTo(FallbackTypeConverter.java:103)[231:org.apache.camel.camel-jaxb:2.12.0.redhat-610379]
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:315)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      at org.apache.camel.core.osgi.OsgiTypeConverter.mandatoryConvertTo(OsgiTypeConverter.java:116)[150:org.apache.camel.camel-blueprint:2.12.0.redhat-610379]
      at org.apache.camel.component.bean.MethodInfo$2.evaluateParameterValue(MethodInfo.java:564)[142:org.apache.camel.camel-core:2.12.0.redhat-610379]
      ... 66 more
  Caused by: javax.xml.bind.UnmarshalException
   - with linked exception:
  [com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element &lt;Value&gt;
   at [row,col {unknown-source}]: [186,77]]
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:426)[128:org.apache.servicemix.bundles.jaxb-impl:2.2.1.1_2]
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)[128:org.apache.servicemix.bundles.jaxb-impl:2.2.1.1_2]
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:332)[128:org.apache.servicemix.bundles.jaxb-impl:2.2.1.1_2]
      at org.apache.camel.converter.jaxb.FallbackTypeConverter.unmarshal(FallbackTypeConverter.java:276)[231:org.apache.camel.camel-jaxb:2.12.0.redhat-610379]
      at org.apache.camel.converter.jaxb.FallbackTypeConverter.unmarshall(FallbackTypeConverter.java:181)[231:org.apache.camel.camel-jaxb:2.12.0.redhat-610379]
      at org.apache.camel.converter.jaxb.FallbackTypeConverter.convertTo(FallbackTypeConverter.java:95)[231:org.apache.camel.camel-jaxb:2.12.0.redhat-610379]
      ... 70 more
  Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element &lt;Value&gt;
   at [row,col {unknown-source}]: [186,77]
      at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)[156:woodstox-core-asl:4.2.0]
      at com.ctc.wstx.sr.BasicStreamReader.throwUnexpectedEOF(BasicStreamReader.java:5532)[156:woodstox-core-asl:4.2.0]
      at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2720)[156:woodstox-core-asl:4.2.0]
      at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1072)[156:woodstox-core-asl:4.2.0]
      at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:192)[128:org.apache.servicemix.bundles.jaxb-impl:2.2.1.1_2]
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)[128:org.apache.servicemix.bundles.jaxb-impl:2.2.1.1_2]
      ... 74 more
  </code></pre>
  
  <p>I think it happens because the way simple language expression executes bean method is to convert message to string, replace placeholder ${in.body} with this string, and execute method, converting this string back to POJO using converter framework. Presence of close parenthesis in this string breaks body of message because it interpreted as close parenthesis for method parameters. Is this true? Any way to resolve this issue? What should be the right way to set header from execution of bean?</p>