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

<<attachment: sandbox.zip>>

Reply via email to