camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: OSGI - camel spring bean - @Handler (java.lang.NullPointerException at org.apache.camel.component.bean.MethodInfo$2.evaluate(MethodInfo.java:197))
Date Tue, 09 Jun 2009 11:00:29 GMT
On Tue, Jun 9, 2009 at 12:03 PM, Charles Moulliard<cmoulliard@gmail.com> wrote:
> Complement of information :
>
> The service (which is packaged as bundle and is deployed as a spring OSGI
> service) publish the interface
>
> <osgi:service ref="requestService"
> interface="com.xpectis.x3s.platform.service.RequestService"/>
>
> while the class implementing the service is declared private and of course
> is instantiated locally by spring.
>
> So we have two different bundles :
>
> A) one containing the routing and where camelContext is created
>
> B) the other which is the service
>
> Question : Can the following method of the bundle B) called while the
> camelcontext runs in the bundle A)  ?

How does you route invoke this bean? Are you refering to it using the
spring bean id?


>
>    @Handler
>    public void createRequest(@Header(value = "messageType") String
> messageType, @Body String body, Exchange exchange) {
>
>        // Instantiate the Request class
>        Request request = new Request();
>
>        // Add the CSV records to the body field
>        request.setMessageContent(body.getBytes());
>
>        // Save the request in the DB
>        this.saveRequest(request);
>
>        // add the request object to the exchange
>        exchange.getOut().setBody(request);
>
>    }
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>
>
> On Tue, Jun 9, 2009 at 11:28 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
>
>> Hi
>>
>> Could be OSGi related. Can you try without OSGi.
>> Just to get the fact straight.
>>
>> And I assume you use 2.0-SNAPSHOT.
>>
>>
>> On Tue, Jun 9, 2009 at 11:18 AM, Charles Moulliard<cmoulliard@gmail.com>
>> wrote:
>> > Hi,
>> >
>> > When I use the following route :
>> >
>> >        <camel:route>
>> >            <camel:from ref="queueClientInEndpoint" />
>> >            <camel:choice>
>> >                <camel:when>
>> >                    <camel:simple>${in.header.messageType} ==
>> > 'OINP'</camel:simple>
>> >                    <!-- Call the requestService to save the request
-->
>> >                    <camel:bean ref="requestService"/>
>> >                </camel:when>
>> >                ....
>> >
>> >    <!-- Request Service  -->
>> >    <osgi:reference id="requestService"
>> > interface="com.xpectis.x3s.platform.service.RequestService" />
>> >
>> >    @Handler
>> >    public void createRequest(@Header(value = "messageType") String
>> > messageType, @Body String body, Exchange exchange) {
>> >
>> >        // Instantiate the Request class
>> >        Request request = new Request();
>> >
>> >        // Add the CSV records to the body field
>> >        request.setMessageContent(body.getBytes());
>> >
>> >        // Save the request in the DB
>> >        this.saveRequest(request);
>> >
>> >        // add the request object to the exchange
>> >        exchange.getOut().setBody(request);
>> >
>> >    }
>> >
>> > , camel generates the following error :
>> >
>> > Caused by: java.lang.NullPointerException
>> >    at
>> >
>> org.apache.camel.component.bean.MethodInfo$2.evaluate(MethodInfo.java:197)
>> >    at
>> >
>> org.apache.camel.component.bean.MethodInfo.createMethodInvocation(MethodInfo.java:81)
>> >    at
>> >
>> org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:151)
>> >    at
>> >
>> org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:104)
>> >    at
>> >
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
>> >    at
>> >
>> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>> >    at
>> >
>> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>> >    at
>> >
>> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:114)
>> >    at
>> >
>> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:52)
>> >    at
>> >
>> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:147)
>> >    at
>> >
>> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>> >    at
>> >
>> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:51)
>> >    at
>> >
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
>> >    at
>> >
>> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>> >    at
>> >
>> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>> >    at
>> >
>> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:114)
>> >    at
>> >
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:61)
>> >    at
>> >
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:61)
>> >    at
>> >
>> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:52)
>> >    at
>> >
>> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:147)
>> >    at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
>> >    at
>> >
>> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
>> >    at
>> >
>> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>> >    at
>> >
>> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:81)
>> >
>> > Is the problem related to the fact that camel can't find the method where
>> > @handler has been defined ?
>> >
>> > Charles Moulliard
>> > Senior Enterprise Architect
>> > Apache Camel Committer
>> >
>> > *****************************
>> > blog : http://cmoulliard.blogspot.com
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message