Hi Chrisrtian, Thanks for the reply. Issue in my case was, handleException of ExceptionHandler class had IOException as method parameter. I removed this method parameter from handleException method and it worked.
I was wondering if there is any way to pass parameters to handleException method bean call from onException(IOException.class).handled(true).bean(ExceptionHandler.class, "handleException"); On Mon, Jul 1, 2013 at 2:57 AM, Christian Müller < christian.muel...@gmail.com> wrote: > This slightly modified unit test is also running successful: > > public class DoCatchDirectRouteTest extends ContextTestSupport { > > public void testDoCatchDirectRoute() throws Exception { > MockEndpoint mock = getMockEndpoint("mock:exception"); > mock.expectedBodiesReceived("Hello World"); > mock.message(0).property(Exchange.EXCEPTION_CAUGHT).isNotNull(); > > > mock.message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IOException.class); > > > mock.message(0).property(Exchange.EXCEPTION_CAUGHT).convertTo(String.class).isEqualTo("Forced"); > > template.sendBody("direct:start", "Hello World"); > > assertMockEndpointsSatisfied(); > } > > @Override > protected RouteBuilder createRouteBuilder() throws Exception { > return new RouteBuilder() { > public void configure() throws Exception { > from("direct:start") > .doTry() > .process(new Processor() { > public void process(Exchange exchange) throws > Exception { > throw new IOException("Forced"); > } > }) > .doCatch(IOException.class) > .to("mock:exception") > .end(); > } > }; > } > } > > Best, > Christian > ----------------- > > Software Integration Specialist > > Apache Camel committer: https://camel.apache.org/team > V.P. Apache Camel: https://www.apache.org/foundation/ > Apache Member: https://www.apache.org/foundation/members.html > > https://www.linkedin.com/pub/christian-mueller/11/551/642 > > > On Sun, Jun 30, 2013 at 12:36 PM, Tarun Kumar <agrawal.taru...@gmail.com > >wrote: > > > Hi, any help will be highly appreciated. In my case, why is my bean > > exception not being propagated to camel route? > > > > > > On Fri, Jun 28, 2013 at 12:38 PM, Tarun Kumar <agrawal.taru...@gmail.com > > >wrote: > > > > > Yes, i have looked all unit tests. > > > > > > In my case, abc method throws IOException. > > > when i surround this bean class with .doTry and > > > .doCatch(IOException.class) blocks, it never goes inside .doCatch(). Is > > > exception from "abc" method is not being propagated to camel route? Why > > > does it not go inside doCatch()? > > > > > > My other ques is how does it know what is inside doCatch block? Does it > > > find it out based on indentation? > > > .doTry().bean() > > > .doCatch() > > > .bean(A.class, "abc") > > > .bean(B.class, "abd") > > > > > > how does it know whether bean call to B.class is inside doCatch or not? > > > > > > > > > > > > > > > On Fri, Jun 28, 2013 at 2:52 AM, Christian Müller < > > > christian.muel...@gmail.com> wrote: > > > > > >> I cannot believe it. > > >> Did you had a look at our unit tests [1]? > > >> > > >> [1] > > >> > > >> > > > https://git-wip-us.apache.org/repos/asf?p=camel.git;a=tree;f=camel-core/src/test/java/org/apache/camel/processor/onexception;h=0b1ada52abb078e9e427b75cd362107557507ffc;hb=HEAD > > >> > > >> Best, > > >> Christian > > >> ----------------- > > >> > > >> Software Integration Specialist > > >> > > >> Apache Camel committer: https://camel.apache.org/team > > >> V.P. Apache Camel: https://www.apache.org/foundation/ > > >> Apache Member: https://www.apache.org/foundation/members.html > > >> > > >> https://www.linkedin.com/pub/christian-mueller/11/551/642 > > >> > > >> > > >> On Thu, Jun 27, 2013 at 10:14 AM, Tarun Kumar < > > agrawal.taru...@gmail.com > > >> >wrote: > > >> > > >> > My route configure method looks like this: > > >> > > > >> > public void configure() { > > >> > > > >> > > > >> > > > onException(IOException.class).handled(true).bean(ExceptionHandler.class, > > >> > "handleException"); > > >> > > > >> > from().process().bean(firstBean.class, "abc").process().end(); > > >> > } > > >> > > > >> > "abc" method of firstBean throws IOException, still, > "handleException" > > >> > method of ExceptionHandler class is not being invoked. What can be > the > > >> > reason? > > >> > > > >> > > > > > > > > >