You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dealbitte <ra...@hotmail.co.uk> on 2012/07/05 11:33:40 UTC

Bean binding @Body and Exchange

Hi,

I have the following camel route (defined in blueprint)


    

    
        
            
            
	    
        
    


In the method "createXML(Exchange exchange)", I create a Document
(org.w3c.dom.Document) and set it as a exchange Body as follows:

exchange.getIn().setBody(doc);

Accessing the Document element in the subsequent method "printXML(Exchange
exchange)" via 

Document xmlDoc = (Document) exchange.getIn().getBody();

does not work as I get the exception "java.lang.AbstractMethodError" as soon
as I drop a file in the dropBox. But if I change the method signature to
 
"printXML(@Body Document xmlDoc)" 

I can retrieve the Document element without any issues. My question would
be,
1. what is the difference, retrieving the Body via annotation (@Body) and
via "exchange.getIn().getBody()"
2. If I use @Body annotation, how can access the 'exchange' inside
'printXML' as I need to set the body of the outgoing message.

Please share your comments.

regards,


--
View this message in context: http://camel.465427.n5.nabble.com/Bean-binding-Body-and-Exchange-tp5715529.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bean binding @Body and Exchange

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jul 6, 2012 at 5:16 PM, dealbitte <ra...@hotmail.co.uk> wrote:
> Dear Claus Ibsen,
>
> The issue got resolved. But it is unclear how it got fixed. I did few things
> (see below) and I am not sure which one did the trick.
>
> re-built the osgi-bundles that provided services (createXML and printXML)
> Executed osgi:refresh (karaf@root> osgi:refresh)
> restarted karaf
>
> and I cannot reproduce the exception anymore. May be you have an idea.
>

Karaf / OSGi is a very modular and dynamic platform. And when you use
bean references then OSGi blueprint will proxy communication with
these beans. And I guess something in there got mixed up. As those
beans are from another bundle (I assume) then it may help refresh /
restart those bundles. Or the Karaf container itself.





> thank you for time,
> Rakesh
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Bean-binding-Body-and-Exchange-tp5715529p5715632.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: Bean binding @Body and Exchange

Posted by dealbitte <ra...@hotmail.co.uk>.
Dear Claus Ibsen,

The issue got resolved. But it is unclear how it got fixed. I did few things
(see below) and I am not sure which one did the trick.

re-built the osgi-bundles that provided services (createXML and printXML)
Executed osgi:refresh (karaf@root> osgi:refresh)
restarted karaf

and I cannot reproduce the exception anymore. May be you have an idea.

thank you for time,
Rakesh





--
View this message in context: http://camel.465427.n5.nabble.com/Bean-binding-Body-and-Exchange-tp5715529p5715632.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bean binding @Body and Exchange

Posted by dealbitte <ra...@hotmail.co.uk>.
Hi, 

I am using camel 2.9.2 installed in Apache Karaf. Java 6 update 33 (java
version "1.6.0_33")

******************** START of Stack trace ********************

karaf@root> log:display-exception
org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange: Exchange[example.txt]
        at
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1237)[64:org.apache.camel.ca
mel-core:2.9.2]
        at
org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:282)[64:org.apache.camel.camel-core:2
.9.2]
        at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:177)[64:org.apache.camel.camel-core:
2.9.2]
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[64:org.apache.camel.camel-co
re:2.9.2]
        at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[64:org.apache.c
amel.camel-core:2.9.2]
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[64:org.apache.camel
.camel-core:2.9.2]
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[64:org.apache.
camel.camel-core:2.9.2]
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[64:org.apache.camel.camel-co
re:2.9.2]
        at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[64:org.apache.c
amel.camel-core:2.9.2]
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[64:org.apache.camel
.camel-core:2.9.2]
        at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)[64:org.apache.camel
.camel-core:2.9.2]
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[64:org.apache.camel.camel-co
re:2.9.2]
        at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:333)[64:org
.apache.camel.camel-core:2.9.2]
        at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:223)[64:org.apache.came
l.camel-core:2.9.2]
        at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[64:org.apache.cam
el.camel-core:2.9.2]
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[64:org.apache.camel
.camel-core:2.9.2]
        at
org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)[64:org.apache.camel.ca
mel-core:2.9.2]
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[64:org.apache.camel.camel-co
re:2.9.2]
        at
org.apache.camel.processor.Pipeline.process(Pipeline.java:117)[64:org.apache.camel.camel-core:2.9.2]
        at
org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[64:org.apache.camel.camel-core:2.9.2]
        at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[64:org.apache.cam
el.camel-core:2.9.2]
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[64:org.apache.camel
.camel-core:2.9.2]
        at
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)[64:org.apache.camel
.camel-core:2.9.2]
        at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)[64:org.apache.camel.came
l-core:2.9.2]
        at
org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java
:50)[64:org.apache.camel.camel-core:2.9.2]
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[64:org.apache.camel
.camel-core:2.9.2]
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[64:org.apache.camel.camel-co
re:2.9.2]
        at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[64:org.apache.c
amel.camel-core:2.9.2]
        at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[64:org.apache.camel
.camel-core:2.9.2]
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[64:org.apache.
camel.camel-core:2.9.2]
        at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:352)[64:org.apac
he.camel.camel-core:2.9.2]
        at
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:175)[64:org.apache.
camel.camel-core:2.9.2]
        at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:136)[64:org.apache.camel.ca
mel-core:2.9.2]
        at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:138)[64:org.apache.camel.camel-c
ore:2.9.2]
        at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:90)[64:org.apache.camel.camel-core
:2.9.2]
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)[:1.6.0_33]
        at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)[:1.6.0_33]
        at
java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)[:1.6.0_33]
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.j
ava:98)[:1.6.0_33]
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.
java:180)[:1.6.0_33]
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204
)[:1.6.0_33]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_33]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_33]
        at java.lang.Thread.run(Thread.java:662)[:1.6.0_33]
Caused by: java.lang.AbstractMethodError
        at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_33]
        at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_33]
        at
org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50)
        at
org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31)
        at
org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
        at $Proxy80.printXML(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor173.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_33]
        at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_33]
        at
org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:340)[64:org.apache.camel.camel-core:2.9.2]
        at
org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:237)[64:org.apache.camel.camel-core:2.9.
2]
        at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:166)[64:org.apache.camel.camel-core:
2.9.2]
        ... 41 more


******************** END of Stack trace ********************

Regards,
Rakesh

--
View this message in context: http://camel.465427.n5.nabble.com/Bean-binding-Body-and-Exchange-tp5715529p5715544.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Bean binding @Body and Exchange

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

Can you post the stacktrace. And what version of Camel are you using?
And what JDK.


On Thu, Jul 5, 2012 at 11:33 AM, dealbitte <ra...@hotmail.co.uk> wrote:
> Hi,
>
> I have the following camel route (defined in blueprint)
>
>
>
>
>
>
>
>
>
>
>
>
>
> In the method "createXML(Exchange exchange)", I create a Document
> (org.w3c.dom.Document) and set it as a exchange Body as follows:
>
> exchange.getIn().setBody(doc);
>
> Accessing the Document element in the subsequent method "printXML(Exchange
> exchange)" via
>
> Document xmlDoc = (Document) exchange.getIn().getBody();
>
> does not work as I get the exception "java.lang.AbstractMethodError" as soon
> as I drop a file in the dropBox. But if I change the method signature to
>
> "printXML(@Body Document xmlDoc)"
>
> I can retrieve the Document element without any issues. My question would
> be,
> 1. what is the difference, retrieving the Body via annotation (@Body) and
> via "exchange.getIn().getBody()"
> 2. If I use @Body annotation, how can access the 'exchange' inside
> 'printXML' as I need to set the body of the outgoing message.
>
> Please share your comments.
>
> regards,
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Bean-binding-Body-and-Exchange-tp5715529.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