You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Shenavai, Manuel" <ma...@sap.com> on 2020/10/07 14:06:27 UTC

OnException and StreamCaching

Hi everyone,

we are using the Camel-onException error handling and found that the exception-handling is sometimes not executed in case of error. When StreamCaching is enabled in the route and an error happens during TypeConversion (see stacktrace below), the exception handling is not executed but the process just fails. I attached a scenario to reproduce the problem to this mail (ExceptionHandling.java).

Is this the expected behavior? If yes, is there a way to make sure that the exception-handling is executed anyways?

Thanks in advance &
Best regards,
Manuel



org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-WDFN34732556A-60796-1602075170410-0-2]

               at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706)
               at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:660)
               at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471)
               at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467)
               at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:139)
               at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:359)
               at parserException.ExceptionHandling.sendMessage(ExceptionHandling.java:28)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
               at java.lang.reflect.Method.invoke(Method.java:498)
               at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
               at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
               at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
               at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
               at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
               at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
               at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
               at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
               at org.junit.rules.RunRules.evaluate(RunRules.java:20)
               at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
               at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
               at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
               at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
               at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
               at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
               at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
               at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
               at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
               at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
               at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
               at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
               at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
               at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
               at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: org.apache.camel.StreamCache with value org.apache.camel.component.cxf.CxfPayload@36328d33 due java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
               at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:629)
               at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:150)
               at org.apache.camel.core.osgi.OsgiTypeConverter.convertTo(OsgiTypeConverter.java:111)
               at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:78)
               at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:53)
               at org.apache.camel.impl.DefaultStreamCachingStrategy.cache(DefaultStreamCachingStrategy.java:189)
               at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:788)
               at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:767)
               at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:145)
               at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
               at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
               at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
               at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
               at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
               at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
               at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
               at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
               at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
               at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
               at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
               at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:221)
               at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
               at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
               ... 30 more
Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
               at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1690)
               at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1285)
               at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59)
               at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:306)
               at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:133)
               ... 51 more
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
               at org.apache.camel.component.cxf.converter.CachedCxfPayload.<init>(CachedCxfPayload.java:50)
               at org.apache.camel.component.cxf.converter.CxfPayloadConverter.cxfPayLoadToStreamCache(CxfPayloadConverter.java:118)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
               at java.lang.reflect.Method.invoke(Method.java:498)
               at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1281)
               ... 54 more

RE: OnException and StreamCaching

Posted by "Shenavai, Manuel" <ma...@sap.com>.
Thanks!

-----Original Message-----
From: Claus Ibsen <cl...@gmail.com> 
Sent: Mittwoch, 28. Oktober 2020 15:37
To: users@camel.apache.org
Subject: Re: OnException and StreamCaching

On 2.x you can set the exchange property with key Exchange.REDELIVERY_EXHAUSTED

On Mon, Oct 26, 2020 at 4:44 PM Shenavai, Manuel
<ma...@sap.com> wrote:
>
> Hi Claus,
>
> thanks for providing a fix for this problem. The fix is available for 3.6.x codeline. We are running on 2.25.x codeline. Is there a chance to get a patch for 2.x as well?
>
> I picked the change in our codeline and found that there is adapt()-method used, that is not available in 2.25:
> exchange.adapt(ExtendedExchange.class).setRedeliveryExhausted(true);
> https://github.com/apache/camel/commit/4cd127eef9f919b36dc761fc495e284e5582663c#diff-9e035215aa8ee92dbb890dc7fe58f4159deb5f2ccf95ed981b0d2b0ed044e8e9R817
>
> Thanks in advance &
> Best regards,
> Manuel
>
> -----Original Message-----
> From: Shenavai, Manuel <ma...@sap.com>
> Sent: Freitag, 9. Oktober 2020 14:47
> To: users@camel.apache.org
> Subject: [CAUTION] RE: OnException and StreamCaching
>
> Hi Claus,
>
> thanks for confirming. I created a Jira for it:
> https://issues.apache.org/jira/browse/CAMEL-15665
>
> Best regards,
> Manuel
>
> -----Original Message-----
> From: Claus Ibsen <cl...@gmail.com>
> Sent: Freitag, 9. Oktober 2020 13:52
> To: users@camel.apache.org
> Subject: Re: OnException and StreamCaching
>
> Hi
>
> Ah thanks for bringing this up. Yeah its a little bug, we should make
> that stream caching more robust.
> You are welcome to create a JIRA
>
> On Wed, Oct 7, 2020 at 4:07 PM Shenavai, Manuel <ma...@sap.com> wrote:
> >
> > Hi everyone,
> >
> >
> >
> > we are using the Camel-onException error handling and found that the exception-handling is sometimes not executed in case of error. When StreamCaching is enabled in the route and an error happens during TypeConversion (see stacktrace below), the exception handling is not executed but the process just fails. I attached a scenario to reproduce the problem to this mail (ExceptionHandling.java).
> >
> >
> >
> > Is this the expected behavior? If yes, is there a way to make sure that the exception-handling is executed anyways?
> >
> >
> >
> > Thanks in advance &
> >
> > Best regards,
> >
> > Manuel
> >
> >
> >
> >
> >
> >
> >
> > org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-WDFN34732556A-60796-1602075170410-0-2]
> >
> >
> >
> >                at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706)
> >
> >                at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:660)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:139)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:359)
> >
> >                at parserException.ExceptionHandling.sendMessage(ExceptionHandling.java:28)
> >
> >                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >
> >                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >                at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
> >
> >                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> >
> >                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
> >
> >                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> >
> >                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> >
> >                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> >
> >                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
> >
> >                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
> >
> >                at org.junit.rules.RunRules.evaluate(RunRules.java:20)
> >
> >                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> >
> >                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> >
> >                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> >
> >                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> >
> >                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> >
> >                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> >
> >                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> >
> >                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> >
> >                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> >
> >                at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> >
> >                at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
> >
> >                at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> >
> >                at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
> >
> >                at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
> >
> >                at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
> >
> > Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: org.apache.camel.StreamCache with value org.apache.camel.component.cxf.CxfPayload@36328d33 due java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
> >
> >                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:629)
> >
> >                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:150)
> >
> >                at org.apache.camel.core.osgi.OsgiTypeConverter.convertTo(OsgiTypeConverter.java:111)
> >
> >                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:78)
> >
> >                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:53)
> >
> >                at org.apache.camel.impl.DefaultStreamCachingStrategy.cache(DefaultStreamCachingStrategy.java:189)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:788)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:767)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:145)
> >
> >                at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
> >
> >                at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
> >
> >                at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
> >
> >                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
> >
> >                at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
> >
> >                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
> >
> >                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
> >
> >                at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
> >
> >                at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
> >
> >                at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:221)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
> >
> >                ... 30 more
> >
> > Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
> >
> >                at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1690)
> >
> >                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1285)
> >
> >                at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59)
> >
> >                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:306)
> >
> >                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:133)
> >
> >                ... 51 more
> >
> > Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
> >
> >                at org.apache.camel.component.cxf.converter.CachedCxfPayload.<init>(CachedCxfPayload.java:50)
> >
> >                at org.apache.camel.component.cxf.converter.CxfPayloadConverter.cxfPayLoadToStreamCache(CxfPayloadConverter.java:118)
> >
> >                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >
> >                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >                at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1281)
> >
> >                ... 54 more
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: OnException and StreamCaching

Posted by Claus Ibsen <cl...@gmail.com>.
On 2.x you can set the exchange property with key Exchange.REDELIVERY_EXHAUSTED

On Mon, Oct 26, 2020 at 4:44 PM Shenavai, Manuel
<ma...@sap.com> wrote:
>
> Hi Claus,
>
> thanks for providing a fix for this problem. The fix is available for 3.6.x codeline. We are running on 2.25.x codeline. Is there a chance to get a patch for 2.x as well?
>
> I picked the change in our codeline and found that there is adapt()-method used, that is not available in 2.25:
> exchange.adapt(ExtendedExchange.class).setRedeliveryExhausted(true);
> https://github.com/apache/camel/commit/4cd127eef9f919b36dc761fc495e284e5582663c#diff-9e035215aa8ee92dbb890dc7fe58f4159deb5f2ccf95ed981b0d2b0ed044e8e9R817
>
> Thanks in advance &
> Best regards,
> Manuel
>
> -----Original Message-----
> From: Shenavai, Manuel <ma...@sap.com>
> Sent: Freitag, 9. Oktober 2020 14:47
> To: users@camel.apache.org
> Subject: [CAUTION] RE: OnException and StreamCaching
>
> Hi Claus,
>
> thanks for confirming. I created a Jira for it:
> https://issues.apache.org/jira/browse/CAMEL-15665
>
> Best regards,
> Manuel
>
> -----Original Message-----
> From: Claus Ibsen <cl...@gmail.com>
> Sent: Freitag, 9. Oktober 2020 13:52
> To: users@camel.apache.org
> Subject: Re: OnException and StreamCaching
>
> Hi
>
> Ah thanks for bringing this up. Yeah its a little bug, we should make
> that stream caching more robust.
> You are welcome to create a JIRA
>
> On Wed, Oct 7, 2020 at 4:07 PM Shenavai, Manuel <ma...@sap.com> wrote:
> >
> > Hi everyone,
> >
> >
> >
> > we are using the Camel-onException error handling and found that the exception-handling is sometimes not executed in case of error. When StreamCaching is enabled in the route and an error happens during TypeConversion (see stacktrace below), the exception handling is not executed but the process just fails. I attached a scenario to reproduce the problem to this mail (ExceptionHandling.java).
> >
> >
> >
> > Is this the expected behavior? If yes, is there a way to make sure that the exception-handling is executed anyways?
> >
> >
> >
> > Thanks in advance &
> >
> > Best regards,
> >
> > Manuel
> >
> >
> >
> >
> >
> >
> >
> > org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-WDFN34732556A-60796-1602075170410-0-2]
> >
> >
> >
> >                at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706)
> >
> >                at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:660)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:139)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:359)
> >
> >                at parserException.ExceptionHandling.sendMessage(ExceptionHandling.java:28)
> >
> >                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >
> >                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >                at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
> >
> >                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> >
> >                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
> >
> >                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> >
> >                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> >
> >                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> >
> >                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
> >
> >                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
> >
> >                at org.junit.rules.RunRules.evaluate(RunRules.java:20)
> >
> >                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
> >
> >                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> >
> >                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
> >
> >                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
> >
> >                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
> >
> >                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
> >
> >                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
> >
> >                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
> >
> >                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> >
> >                at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
> >
> >                at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
> >
> >                at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> >
> >                at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
> >
> >                at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
> >
> >                at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
> >
> > Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: org.apache.camel.StreamCache with value org.apache.camel.component.cxf.CxfPayload@36328d33 due java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
> >
> >                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:629)
> >
> >                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:150)
> >
> >                at org.apache.camel.core.osgi.OsgiTypeConverter.convertTo(OsgiTypeConverter.java:111)
> >
> >                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:78)
> >
> >                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:53)
> >
> >                at org.apache.camel.impl.DefaultStreamCachingStrategy.cache(DefaultStreamCachingStrategy.java:189)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:788)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:767)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:145)
> >
> >                at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
> >
> >                at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
> >
> >                at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
> >
> >                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
> >
> >                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
> >
> >                at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
> >
> >                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
> >
> >                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
> >
> >                at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
> >
> >                at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
> >
> >                at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:221)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
> >
> >                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
> >
> >                ... 30 more
> >
> > Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
> >
> >                at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1690)
> >
> >                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1285)
> >
> >                at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59)
> >
> >                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:306)
> >
> >                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:133)
> >
> >                ... 51 more
> >
> > Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
> >
> >                at org.apache.camel.component.cxf.converter.CachedCxfPayload.<init>(CachedCxfPayload.java:50)
> >
> >                at org.apache.camel.component.cxf.converter.CxfPayloadConverter.cxfPayLoadToStreamCache(CxfPayloadConverter.java:118)
> >
> >                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >
> >                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >                at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1281)
> >
> >                ... 54 more
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

RE: OnException and StreamCaching

Posted by "Shenavai, Manuel" <ma...@sap.com>.
Hi Claus,

thanks for providing a fix for this problem. The fix is available for 3.6.x codeline. We are running on 2.25.x codeline. Is there a chance to get a patch for 2.x as well?

I picked the change in our codeline and found that there is adapt()-method used, that is not available in 2.25:
exchange.adapt(ExtendedExchange.class).setRedeliveryExhausted(true);
https://github.com/apache/camel/commit/4cd127eef9f919b36dc761fc495e284e5582663c#diff-9e035215aa8ee92dbb890dc7fe58f4159deb5f2ccf95ed981b0d2b0ed044e8e9R817

Thanks in advance &
Best regards,
Manuel

-----Original Message-----
From: Shenavai, Manuel <ma...@sap.com> 
Sent: Freitag, 9. Oktober 2020 14:47
To: users@camel.apache.org
Subject: [CAUTION] RE: OnException and StreamCaching

Hi Claus,

thanks for confirming. I created a Jira for it:
https://issues.apache.org/jira/browse/CAMEL-15665

Best regards,
Manuel

-----Original Message-----
From: Claus Ibsen <cl...@gmail.com> 
Sent: Freitag, 9. Oktober 2020 13:52
To: users@camel.apache.org
Subject: Re: OnException and StreamCaching

Hi

Ah thanks for bringing this up. Yeah its a little bug, we should make
that stream caching more robust.
You are welcome to create a JIRA

On Wed, Oct 7, 2020 at 4:07 PM Shenavai, Manuel <ma...@sap.com> wrote:
>
> Hi everyone,
>
>
>
> we are using the Camel-onException error handling and found that the exception-handling is sometimes not executed in case of error. When StreamCaching is enabled in the route and an error happens during TypeConversion (see stacktrace below), the exception handling is not executed but the process just fails. I attached a scenario to reproduce the problem to this mail (ExceptionHandling.java).
>
>
>
> Is this the expected behavior? If yes, is there a way to make sure that the exception-handling is executed anyways?
>
>
>
> Thanks in advance &
>
> Best regards,
>
> Manuel
>
>
>
>
>
>
>
> org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-WDFN34732556A-60796-1602075170410-0-2]
>
>
>
>                at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706)
>
>                at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:660)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:139)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:359)
>
>                at parserException.ExceptionHandling.sendMessage(ExceptionHandling.java:28)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
>                at java.lang.reflect.Method.invoke(Method.java:498)
>
>                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
>
>                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>
>                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
>
>                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>
>                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>
>                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>
>                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
>
>                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
>
>                at org.junit.rules.RunRules.evaluate(RunRules.java:20)
>
>                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
>
>                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
>
>                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>
>                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
>
>                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
>
>                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
>
>                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
>
>                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
>
>                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>
>                at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
>
>                at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
>
>                at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
>
>                at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
>
>                at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
>
>                at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
>
> Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: org.apache.camel.StreamCache with value org.apache.camel.component.cxf.CxfPayload@36328d33 due java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:629)
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:150)
>
>                at org.apache.camel.core.osgi.OsgiTypeConverter.convertTo(OsgiTypeConverter.java:111)
>
>                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:78)
>
>                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:53)
>
>                at org.apache.camel.impl.DefaultStreamCachingStrategy.cache(DefaultStreamCachingStrategy.java:189)
>
>                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:788)
>
>                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:767)
>
>                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:145)
>
>                at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
>
>                at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
>
>                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>
>                at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
>
>                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>
>                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
>
>                at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
>
>                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
>
>                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
>
>                at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
>
>                at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
>
>                at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:221)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
>
>                ... 30 more
>
> Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
>
>                at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1690)
>
>                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1285)
>
>                at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59)
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:306)
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:133)
>
>                ... 51 more
>
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
>
>                at org.apache.camel.component.cxf.converter.CachedCxfPayload.<init>(CachedCxfPayload.java:50)
>
>                at org.apache.camel.component.cxf.converter.CxfPayloadConverter.cxfPayLoadToStreamCache(CxfPayloadConverter.java:118)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
>                at java.lang.reflect.Method.invoke(Method.java:498)
>
>                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1281)
>
>                ... 54 more



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

RE: OnException and StreamCaching

Posted by "Shenavai, Manuel" <ma...@sap.com>.
Hi Claus,

thanks for confirming. I created a Jira for it:
https://issues.apache.org/jira/browse/CAMEL-15665

Best regards,
Manuel

-----Original Message-----
From: Claus Ibsen <cl...@gmail.com> 
Sent: Freitag, 9. Oktober 2020 13:52
To: users@camel.apache.org
Subject: Re: OnException and StreamCaching

Hi

Ah thanks for bringing this up. Yeah its a little bug, we should make
that stream caching more robust.
You are welcome to create a JIRA

On Wed, Oct 7, 2020 at 4:07 PM Shenavai, Manuel <ma...@sap.com> wrote:
>
> Hi everyone,
>
>
>
> we are using the Camel-onException error handling and found that the exception-handling is sometimes not executed in case of error. When StreamCaching is enabled in the route and an error happens during TypeConversion (see stacktrace below), the exception handling is not executed but the process just fails. I attached a scenario to reproduce the problem to this mail (ExceptionHandling.java).
>
>
>
> Is this the expected behavior? If yes, is there a way to make sure that the exception-handling is executed anyways?
>
>
>
> Thanks in advance &
>
> Best regards,
>
> Manuel
>
>
>
>
>
>
>
> org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-WDFN34732556A-60796-1602075170410-0-2]
>
>
>
>                at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706)
>
>                at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:660)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:139)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:359)
>
>                at parserException.ExceptionHandling.sendMessage(ExceptionHandling.java:28)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
>                at java.lang.reflect.Method.invoke(Method.java:498)
>
>                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
>
>                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>
>                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
>
>                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>
>                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>
>                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>
>                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
>
>                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
>
>                at org.junit.rules.RunRules.evaluate(RunRules.java:20)
>
>                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
>
>                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
>
>                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>
>                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
>
>                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
>
>                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
>
>                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
>
>                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
>
>                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>
>                at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
>
>                at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
>
>                at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
>
>                at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
>
>                at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
>
>                at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
>
> Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: org.apache.camel.StreamCache with value org.apache.camel.component.cxf.CxfPayload@36328d33 due java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:629)
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:150)
>
>                at org.apache.camel.core.osgi.OsgiTypeConverter.convertTo(OsgiTypeConverter.java:111)
>
>                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:78)
>
>                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:53)
>
>                at org.apache.camel.impl.DefaultStreamCachingStrategy.cache(DefaultStreamCachingStrategy.java:189)
>
>                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:788)
>
>                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:767)
>
>                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:145)
>
>                at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
>
>                at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
>
>                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>
>                at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
>
>                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>
>                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
>
>                at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
>
>                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
>
>                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
>
>                at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
>
>                at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
>
>                at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:221)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
>
>                ... 30 more
>
> Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
>
>                at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1690)
>
>                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1285)
>
>                at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59)
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:306)
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:133)
>
>                ... 51 more
>
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
>
>                at org.apache.camel.component.cxf.converter.CachedCxfPayload.<init>(CachedCxfPayload.java:50)
>
>                at org.apache.camel.component.cxf.converter.CxfPayloadConverter.cxfPayLoadToStreamCache(CxfPayloadConverter.java:118)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
>                at java.lang.reflect.Method.invoke(Method.java:498)
>
>                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1281)
>
>                ... 54 more



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: OnException and StreamCaching

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

Ah thanks for bringing this up. Yeah its a little bug, we should make
that stream caching more robust.
You are welcome to create a JIRA

On Wed, Oct 7, 2020 at 4:07 PM Shenavai, Manuel <ma...@sap.com> wrote:
>
> Hi everyone,
>
>
>
> we are using the Camel-onException error handling and found that the exception-handling is sometimes not executed in case of error. When StreamCaching is enabled in the route and an error happens during TypeConversion (see stacktrace below), the exception handling is not executed but the process just fails. I attached a scenario to reproduce the problem to this mail (ExceptionHandling.java).
>
>
>
> Is this the expected behavior? If yes, is there a way to make sure that the exception-handling is executed anyways?
>
>
>
> Thanks in advance &
>
> Best regards,
>
> Manuel
>
>
>
>
>
>
>
> org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-WDFN34732556A-60796-1602075170410-0-2]
>
>
>
>                at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706)
>
>                at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:660)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:139)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:359)
>
>                at parserException.ExceptionHandling.sendMessage(ExceptionHandling.java:28)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
>                at java.lang.reflect.Method.invoke(Method.java:498)
>
>                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
>
>                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>
>                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
>
>                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>
>                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>
>                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>
>                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
>
>                at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
>
>                at org.junit.rules.RunRules.evaluate(RunRules.java:20)
>
>                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
>
>                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
>
>                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>
>                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
>
>                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
>
>                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
>
>                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
>
>                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
>
>                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>
>                at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
>
>                at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
>
>                at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
>
>                at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
>
>                at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
>
>                at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
>
> Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: org.apache.camel.StreamCache with value org.apache.camel.component.cxf.CxfPayload@36328d33 due java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:629)
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:150)
>
>                at org.apache.camel.core.osgi.OsgiTypeConverter.convertTo(OsgiTypeConverter.java:111)
>
>                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:78)
>
>                at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:53)
>
>                at org.apache.camel.impl.DefaultStreamCachingStrategy.cache(DefaultStreamCachingStrategy.java:189)
>
>                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:788)
>
>                at org.apache.camel.processor.CamelInternalProcessor$StreamCachingAdvice.before(CamelInternalProcessor.java:767)
>
>                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:145)
>
>                at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
>
>                at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
>
>                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>
>                at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
>
>                at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>
>                at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
>
>                at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
>
>                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
>
>                at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
>
>                at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
>
>                at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
>
>                at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:221)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:124)
>
>                at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:137)
>
>                ... 30 more
>
> Caused by: org.apache.camel.RuntimeCamelException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
>
>                at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1690)
>
>                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1285)
>
>                at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59)
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:306)
>
>                at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:133)
>
>                ... 51 more
>
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to javax.xml.transform.Source
>
>                at org.apache.camel.component.cxf.converter.CachedCxfPayload.<init>(CachedCxfPayload.java:50)
>
>                at org.apache.camel.component.cxf.converter.CxfPayloadConverter.cxfPayLoadToStreamCache(CxfPayloadConverter.java:118)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
>                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
>                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
>                at java.lang.reflect.Method.invoke(Method.java:498)
>
>                at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1281)
>
>                ... 54 more



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2