Hi Ryan,

The following Camel DSL:

to("bean:beanClass?method=methodToCall(${body})")

or

bean(BeanClass.class, "methodToCall(${body})")

Does not convert the body to String when the type of body corresponds to that 
of the first method parameter.

Is there any step upfront in your route that may convert the body to String?

The error that you have can occur when quotes are added to type declaration 
like:

to("bean:beanClass?method=processBody('org.apache.camel.cdi.se.bean.Pojo')")
                                                                     ^          
                                              ^
instead of:

to("bean:beanClass?method=processBody(org.apache.camel.cdi.se.bean.Pojo)")

Could you share you exact piece of route and bean class?

Antonin

> On 12 Nov 2015, at 18:20, Ryan Moquin <[email protected]> wrote:
> 
> Hi, I'm using Camel 2.16.0 and trying to invoke a bean method using spring
> xml and having some issues.  It seems like any time I try to invoke a bean
> method with a camel message body, camel tries to pass it as a string to the
> method (even though the method takes the class as an argument) I'm calling
> even though the body type is correctly set to the java class type and the
> body itself is a class.  I've called bean methods a lot from Camel and
> don't remember this being normal behavior?  Or am I wrong?
> 
> Caused by: org.apache.camel.component.bean.ParameterBindingException: Error
> during parameter binding on method: public java.lang.String
> com.test.TestService.retrieve(com.test.bo.TestObject,java.util.Date,com.test.TestParam)
> at parameter #0 with type: class com.test.bo.TestObject with value type:
> class java.lang.String and value: com.test.bo.TestObject
>        at
> org.apache.camel.component.bean.MethodInfo$2.evaluateParameterValue(MethodInfo.java:582)
>        ...
> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
> converter available to convert from type: java.lang.String to the required
> type: com.test.bo.TestObject with value com.test.bo.TestObject
>        at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:1
> 85)
> 
> I'm just calling the bean method like you normally would.  I can log the
> value of a property of the java class in the body using a log statement
> right before I do the invocation of the method.  I don't do anything
> special when calling the method other than putting the first parameter as:
> ${body}
> 
> Is this by design in Camel and I never noticed?  If so, is there any way
> around it?
> 
> Thanks for any help!
> Ryan

Reply via email to