You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "me.mehta" <me...@gmail.com> on 2012/08/29 10:24:17 UTC

Using custom bean for splitter using spring camel.

I am using following xml configuration for defining a custom bean for
splitter. 

  <camel:split stopOnException="true">
      <camel:method bean="splitterBean" method="split" /> 
       <camel:to ref="sodSQLEndPoint"/>
    </camel:split>

 <bean id="splitterBean" class="com.processor.SodFundListSplitter" />

It doesn't run and gives an error:

12:31:28.770 [main] WARN  org.apache.camel.util.ObjectHelper - Cannot find
class: splitterBean.

If I use <camel:simple>body</camel:simple> instead of the custome bean, it
works fine. Can anyone please tell me if there is anything extra to be done
for allowing custom bean with splitter.



--
View this message in context: http://camel.465427.n5.nabble.com/Using-custom-bean-for-splitter-using-spring-camel-tp5718236.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using custom bean for splitter using spring camel.

Posted by "me.mehta" <me...@gmail.com>.
I made few changes and my custom bean is being called now. 

    <camel:split stopOnException="true">
      <camel:method bean="com.processor.SodFundListSplitter" method="split"
/> 
       <camel:to ref="sodSQLEndPoint"/>
    </camel:split>

and changed method in bean to 

public class SodFundListSplitter {
 
   @SuppressWarnings("unchecked")
    public List<String> split(Exchange exchange) {
        return exchange.getIn().getBody(List.class);
    }
}

But I need to use the splitterBean at more than one places in the context.
So I am not convinced to write it inline at every place. I tries using ref
as well instead on bean in the camel:method, but invain. 



--
View this message in context: http://camel.465427.n5.nabble.com/Using-custom-bean-for-splitter-using-spring-camel-tp5718236p5718364.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using custom bean for splitter using spring camel.

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Aug 30, 2012 at 11:33 AM, me.mehta <me...@gmail.com> wrote:
> Sorry for replying late on the thread.
> The custom bean as of now is very simple. Just getting and returning the
> list. I just wanted to check if its working before actually writing the code
> in custom bean. So its like
>
> public class SodFundListSplitter {
>
>     public List<String> split(List<String> inputList) {
>         return inputList;
>     }
>

Can you try without the generics in the parameter list

     public List<String> split(List inputList)

and

     public List split(List inputList)


>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Using-custom-bean-for-splitter-using-spring-camel-tp5718236p5718360.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Using custom bean for splitter using spring camel.

Posted by "me.mehta" <me...@gmail.com>.
Sorry for replying late on the thread.
The custom bean as of now is very simple. Just getting and returning the
list. I just wanted to check if its working before actually writing the code
in custom bean. So its like 

public class SodFundListSplitter {

    public List<String> split(List<String> inputList) {
        return inputList;
    }



--
View this message in context: http://camel.465427.n5.nabble.com/Using-custom-bean-for-splitter-using-spring-camel-tp5718236p5718360.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using custom bean for splitter using spring camel.

Posted by Christian Müller <ch...@gmail.com>.
Could you share the bean code with us?

Sent from a mobile device
Am 29.08.2012 10:29 schrieb "me.mehta" <me...@gmail.com>:

> I am using following xml configuration for defining a custom bean for
> splitter.
>
>   <camel:split stopOnException="true">
>       <camel:method bean="splitterBean" method="split" />
>        <camel:to ref="sodSQLEndPoint"/>
>     </camel:split>
>
>  <bean id="splitterBean" class="com.processor.SodFundListSplitter" />
>
> It doesn't run and gives an error:
>
> 12:31:28.770 [main] WARN  org.apache.camel.util.ObjectHelper - Cannot find
> class: splitterBean.
>
> If I use <camel:simple>body</camel:simple> instead of the custome bean, it
> works fine. Can anyone please tell me if there is anything extra to be done
> for allowing custom bean with splitter.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Using-custom-bean-for-splitter-using-spring-camel-tp5718236.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Using custom bean for splitter using spring camel.

Posted by "me.mehta" <me...@gmail.com>.
Also I have other beans within the same context where splitterBean is
defined, and those are referred from the camel routes. Working fine. Not
able to find out why this bean is not working. 



--
View this message in context: http://camel.465427.n5.nabble.com/Using-custom-bean-for-splitter-using-spring-camel-tp5718236p5718247.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using custom bean for splitter using spring camel.

Posted by "me.mehta" <me...@gmail.com>.
I am using camel 2.6, and running it through spring



--
View this message in context: http://camel.465427.n5.nabble.com/Using-custom-bean-for-splitter-using-spring-camel-tp5718236p5718245.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using custom bean for splitter using spring camel.

Posted by londonukm <gr...@outlook.com>.
Hi, 

Given that its working without the use of the custom bean, I would say that
your bean is either not registered, or is registered but in another context.

Thanks

Graham



--
View this message in context: http://camel.465427.n5.nabble.com/Using-custom-bean-for-splitter-using-spring-camel-tp5718236p5718242.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using custom bean for splitter using spring camel.

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

What Camel version do you use?
Also how do you run this. Do you use Spring or OSGi or what?


On Wed, Aug 29, 2012 at 10:24 AM, me.mehta <me...@gmail.com> wrote:
> I am using following xml configuration for defining a custom bean for
> splitter.
>
>   <camel:split stopOnException="true">
>       <camel:method bean="splitterBean" method="split" />
>        <camel:to ref="sodSQLEndPoint"/>
>     </camel:split>
>
>  <bean id="splitterBean" class="com.processor.SodFundListSplitter" />
>
> It doesn't run and gives an error:
>
> 12:31:28.770 [main] WARN  org.apache.camel.util.ObjectHelper - Cannot find
> class: splitterBean.
>
> If I use <camel:simple>body</camel:simple> instead of the custome bean, it
> works fine. Can anyone please tell me if there is anything extra to be done
> for allowing custom bean with splitter.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Using-custom-bean-for-splitter-using-spring-camel-tp5718236.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen