You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Castyn <er...@gmail.com> on 2012/04/11 22:17:27 UTC

Trapping Errors Help

I am trying to trap errors thrown in camel and am running into a bit of an
issue with nested errors.  For example:

org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
	at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:237)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
	at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:60)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
	at
org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:779)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1498)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
	at
org.apache.cxf.workqueue.AutomaticWorkQueueImpl$2.run(AutomaticWorkQueueImpl.java:353)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_23]
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_23]
	at java.lang.Thread.run(Thread.java:662)[:1.6.0_23]
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
 at [row,col {unknown-source}]: [1,0]
	at
com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)[127:woodstox-core-asl:4.1.1]
	at
com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2104)[127:woodstox-core-asl:4.1.1]
	at
com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2010)[127:woodstox-core-asl:4.1.1]
	at
com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1102)[127:woodstox-core-asl:4.1.1]
	at
com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1125)[127:woodstox-core-asl:4.1.1]
	at
org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:138)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
	... 9 more


I know I can catch this error in the camel spring DSL using something like 

		    <onException>
			    <exception>org.apache.cxf.interceptor.Fault</exception>
			    <redeliveryPolicy maximumRedeliveries="0" />
			    <handled><constant>true</constant></handled>
			    <log message="CXF Fault" loggingLevel="ERROR"/>
		    </onException>

But obviously that is a fairly generic case of a soap fault error being
thrown by cxf, and I'd actually want to catch the more specific error, in
this case com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog.

I have tried adding an onException block for that error, but for some reason
when I attempt to deploy it it gives me a class not found error on
com.ctc.wstx.exc.WstxEOFException.  I have included the
org.codehaus.woodstox/woodstox-core-asl in my POM and made sure the osgi
bundle imports the com.ctc.wstx.exc package, but for some reason it can not
work out this dependency.  

Am I doing something obvious improperly?  Is there a different method I
should go about trying to trap route errors?

--
View this message in context: http://camel.465427.n5.nabble.com/Trapping-Errors-Help-tp5633932p5633932.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Trapping Errors Help

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

Ah it could be because getClass is from java.lang.Object which we
filter out usually.
Could you log a JIRA?


On Wed, Apr 18, 2012 at 7:26 PM, Castyn <er...@gmail.com> wrote:
> For some reason when I try that and the error is attempted to be captured I
> am getting an error in the simple expression.  I am not sure why $exception
> seems to be null.
>
> The full exception block I am using is
>
>                    <onException>
>                            <exception>org.apache.cxf.interceptor.Fault</exception>
>                            <onWhen>
>                                <simple>${exception.getClass().getSimpleName()} ==
> 'WstxEOFException'</simple>
>                            </onWhen>
>                            <redeliveryPolicy maximumRedeliveries="0" />
>                            <handled><constant>true</constant></handled>
>                            <log message="Server is not available (EOF Exception)"/>
>                            <process ref="soapFaultProcessor" />
>                    </onException>
>
>
>
> 13:12:26,535 | ERROR | ault-workqueue-5 | DefaultErrorHandler              |
> ?                                   ? | 89 - org.apache.camel.camel-core -
> 2.8.0.fuse-01-13 | Failed delivery for exchangeId:
> ID-adcinitiated1-36263-1334673739090-3-2670. Exhausted after delivery
> attempt: 1 caught:
> org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
> invoke method: .getClass().getSimpleName() on null due to:
> org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
> invoke method: getClass() on null due to:
> org.apache.camel.component.bean.MethodNotFoundException: Method with name:
> getClass() not found on bean: org.apache.cxf.binding.soap.SoapFault: Fault
> occurred while processing.. Exchange[Message: [Body is null]]
> org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
> invoke method: .getClass().getSimpleName() on null due to:
> org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
> invoke method: getClass() on null due to:
> org.apache.camel.component.bean.MethodNotFoundException: Method with name:
> getClass() not found on bean: org.apache.cxf.binding.soap.SoapFault: Fault
> occurred while processing.. Exchange[Message: [Body is null]]
>        at
> org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:86)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:101)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:119)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:111)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.builder.ExpressionBuilder$12.evaluate(ExpressionBuilder.java:344)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.impl.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.builder.BinaryPredicateSupport.matchesReturningFailureMessage(BinaryPredicateSupport.java:60)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.builder.BinaryPredicateSupport.matches(BinaryPredicateSupport.java:50)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.language.simple.SimpleLanguageSupport$2.evaluate(SimpleLanguageSupport.java:278)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.builder.PredicateBuilder$1.matches(PredicateBuilder.java:53)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.language.simple.SimpleLanguageSupport$1.evaluate(SimpleLanguageSupport.java:133)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.builder.PredicateBuilder$1.matches(PredicateBuilder.java:53)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:75)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.model.language.ExpressionDefinition.matches(ExpressionDefinition.java:133)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.processor.exceptionpolicy.DefaultExceptionPolicyStrategy.matchesWhen(DefaultExceptionPolicyStrategy.java:229)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.processor.exceptionpolicy.DefaultExceptionPolicyStrategy.findMatchedExceptionPolicy(DefaultExceptionPolicyStrategy.java:151)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.processor.exceptionpolicy.DefaultExceptionPolicyStrategy.getExceptionPolicy(DefaultExceptionPolicyStrategy.java:77)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.processor.ErrorHandlerSupport.getExceptionPolicy(ErrorHandlerSupport.java:94)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.handleException(RedeliveryErrorHandler.java:596)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.processAsyncErrorHandler(RedeliveryErrorHandler.java:377)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.processor.RedeliveryErrorHandler$1.done(RedeliveryErrorHandler.java:336)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.impl.ProducerCache$1.done(ProducerCache.java:307)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.processor.SendProcessor$2$1.done(SendProcessor.java:119)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.component.cxf.CxfClientCallback.handleException(CxfClientCallback.java:80)[143:org.apache.camel.camel-cxf:2.8.0.fuse-01-13]
>        at
> org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:820)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1498)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$2.run(AutomaticWorkQueueImpl.java:353)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_23]
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_23]
>        at java.lang.Thread.run(Thread.java:662)[:1.6.0_23]
> Caused by: org.apache.camel.language.bean.RuntimeBeanExpressionException:
> Failed to invoke method: getClass() on null due to:
> org.apache.camel.component.bean.MethodNotFoundException: Method with name:
> getClass() not found on bean: org.apache.cxf.binding.soap.SoapFault: Fault
> occurred while processing.. Exchange[Message: [Body is null]]
>        at
> org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:220)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:83)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        ... 31 more
> Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method
> with name: getClass() not found on bean:
> org.apache.cxf.binding.soap.SoapFault: Fault occurred while processing..
> Exchange[Message: [Body is null]]
>        at
> org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:172)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:151)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:104)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:74)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:139)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        at
> org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:216)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
>        ... 32 more
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Trapping-Errors-Help-tp5633932p5649758.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Trapping Errors Help

Posted by Castyn <er...@gmail.com>.
For some reason when I try that and the error is attempted to be captured I
am getting an error in the simple expression.  I am not sure why $exception
seems to be null.

The full exception block I am using is 

		    <onException>
			    <exception>org.apache.cxf.interceptor.Fault</exception>
			    <onWhen>
			    	<simple>${exception.getClass().getSimpleName()} ==
'WstxEOFException'</simple>
			    </onWhen>
			    <redeliveryPolicy maximumRedeliveries="0" />
			    <handled><constant>true</constant></handled>
			    <log message="Server is not available (EOF Exception)"/>
			    <process ref="soapFaultProcessor" /> 
		    </onException>



13:12:26,535 | ERROR | ault-workqueue-5 | DefaultErrorHandler              |
?                                   ? | 89 - org.apache.camel.camel-core -
2.8.0.fuse-01-13 | Failed delivery for exchangeId:
ID-adcinitiated1-36263-1334673739090-3-2670. Exhausted after delivery
attempt: 1 caught:
org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
invoke method: .getClass().getSimpleName() on null due to:
org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
invoke method: getClass() on null due to:
org.apache.camel.component.bean.MethodNotFoundException: Method with name:
getClass() not found on bean: org.apache.cxf.binding.soap.SoapFault: Fault
occurred while processing.. Exchange[Message: [Body is null]]
org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
invoke method: .getClass().getSimpleName() on null due to:
org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to
invoke method: getClass() on null due to:
org.apache.camel.component.bean.MethodNotFoundException: Method with name:
getClass() not found on bean: org.apache.cxf.binding.soap.SoapFault: Fault
occurred while processing.. Exchange[Message: [Body is null]]
        at
org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:86)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:101)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:119)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:111)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.builder.ExpressionBuilder$12.evaluate(ExpressionBuilder.java:344)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.impl.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.builder.BinaryPredicateSupport.matchesReturningFailureMessage(BinaryPredicateSupport.java:60)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.builder.BinaryPredicateSupport.matches(BinaryPredicateSupport.java:50)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.language.simple.SimpleLanguageSupport$2.evaluate(SimpleLanguageSupport.java:278)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.builder.PredicateBuilder$1.matches(PredicateBuilder.java:53)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.language.simple.SimpleLanguageSupport$1.evaluate(SimpleLanguageSupport.java:133)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.builder.PredicateBuilder$1.matches(PredicateBuilder.java:53)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:75)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.model.language.ExpressionDefinition.matches(ExpressionDefinition.java:133)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.processor.exceptionpolicy.DefaultExceptionPolicyStrategy.matchesWhen(DefaultExceptionPolicyStrategy.java:229)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.processor.exceptionpolicy.DefaultExceptionPolicyStrategy.findMatchedExceptionPolicy(DefaultExceptionPolicyStrategy.java:151)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.processor.exceptionpolicy.DefaultExceptionPolicyStrategy.getExceptionPolicy(DefaultExceptionPolicyStrategy.java:77)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.processor.ErrorHandlerSupport.getExceptionPolicy(ErrorHandlerSupport.java:94)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.processor.RedeliveryErrorHandler.handleException(RedeliveryErrorHandler.java:596)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.processor.RedeliveryErrorHandler.processAsyncErrorHandler(RedeliveryErrorHandler.java:377)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.processor.RedeliveryErrorHandler$1.done(RedeliveryErrorHandler.java:336)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.impl.ProducerCache$1.done(ProducerCache.java:307)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.processor.SendProcessor$2$1.done(SendProcessor.java:119)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.component.cxf.CxfClientCallback.handleException(CxfClientCallback.java:80)[143:org.apache.camel.camel-cxf:2.8.0.fuse-01-13]
        at
org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:820)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
        at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1498)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
        at
org.apache.cxf.workqueue.AutomaticWorkQueueImpl$2.run(AutomaticWorkQueueImpl.java:353)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_23]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_23]
        at java.lang.Thread.run(Thread.java:662)[:1.6.0_23]
Caused by: org.apache.camel.language.bean.RuntimeBeanExpressionException:
Failed to invoke method: getClass() on null due to:
org.apache.camel.component.bean.MethodNotFoundException: Method with name:
getClass() not found on bean: org.apache.cxf.binding.soap.SoapFault: Fault
occurred while processing.. Exchange[Message: [Body is null]]
        at
org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:220)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:83)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        ... 31 more
Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method
with name: getClass() not found on bean:
org.apache.cxf.binding.soap.SoapFault: Fault occurred while processing..
Exchange[Message: [Body is null]]
        at
org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:172)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:151)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:104)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:74)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:139)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        at
org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:216)[89:org.apache.camel.camel-core:2.8.0.fuse-01-13]
        ... 32 more


--
View this message in context: http://camel.465427.n5.nabble.com/Trapping-Errors-Help-tp5633932p5649758.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Trapping Errors Help

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Apr 12, 2012 at 6:17 PM, Castyn <er...@gmail.com> wrote:
> That's a nice little trick with the onWhen, I like it.
>
> Where does that fall in the scope of the exception block?
>
> Would it just run something like the following?  After the onWhen runs does
> the flow pass through the to the statements afterwards, or is there some
> sort of "else" clause I need to use to control flow more?
>

No its part of the <exception>, so its just an *extra* check, that it
must be that kind of exception, and the onWhen predicate must *also*
be true.
So it should be after <exception>

> <onException>
>    <exception>org.apache.cxf.interceptor.Fault</exception>
>    <redeliveryPolicy maximumRedeliveries="0" />
>    <handled><constant>true</constant></handled>
>    <onWhen>
>        <simple>${exception.getClass().getSimpleName()} ==
> 'WstxEOFException'</simple>
>        <log message="Woodstock XML Exception"/>
>    </onWhen>
>    <log message="CXF Fault" loggingLevel="ERROR"/>
> </onException>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Trapping-Errors-Help-tp5633932p5636126.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Trapping Errors Help

Posted by Castyn <er...@gmail.com>.
That's a nice little trick with the onWhen, I like it.

Where does that fall in the scope of the exception block?

Would it just run something like the following?  After the onWhen runs does
the flow pass through the to the statements afterwards, or is there some
sort of "else" clause I need to use to control flow more?

<onException> 
    <exception>org.apache.cxf.interceptor.Fault</exception> 
    <redeliveryPolicy maximumRedeliveries="0" /> 
    <handled><constant>true</constant></handled>
    <onWhen> 
        <simple>${exception.getClass().getSimpleName()} ==
'WstxEOFException'</simple> 
        <log message="Woodstock XML Exception"/>
    </onWhen>
    <log message="CXF Fault" loggingLevel="ERROR"/> 
</onException> 

--
View this message in context: http://camel.465427.n5.nabble.com/Trapping-Errors-Help-tp5633932p5636126.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Trapping Errors Help

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Apr 11, 2012 at 10:17 PM, Castyn <er...@gmail.com> wrote:
> I am trying to trap errors thrown in camel and am running into a bit of an
> issue with nested errors.  For example:
>
> org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
>        at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:237)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:60)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:779)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1498)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$2.run(AutomaticWorkQueueImpl.java:353)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_23]
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_23]
>        at java.lang.Thread.run(Thread.java:662)[:1.6.0_23]
> Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
>  at [row,col {unknown-source}]: [1,0]
>        at
> com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)[127:woodstox-core-asl:4.1.1]
>        at
> com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2104)[127:woodstox-core-asl:4.1.1]
>        at
> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2010)[127:woodstox-core-asl:4.1.1]
>        at
> com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1102)[127:woodstox-core-asl:4.1.1]
>        at
> com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1125)[127:woodstox-core-asl:4.1.1]
>        at
> org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:138)[133:org.apache.cxf.bundle:2.4.3.fuse-00-13]
>        ... 9 more
>
>
> I know I can catch this error in the camel spring DSL using something like
>
>                    <onException>
>                            <exception>org.apache.cxf.interceptor.Fault</exception>
>                            <redeliveryPolicy maximumRedeliveries="0" />
>                            <handled><constant>true</constant></handled>
>                            <log message="CXF Fault" loggingLevel="ERROR"/>
>                    </onException>
>
> But obviously that is a fairly generic case of a soap fault error being
> thrown by cxf, and I'd actually want to catch the more specific error, in
> this case com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog.
>
> I have tried adding an onException block for that error, but for some reason
> when I attempt to deploy it it gives me a class not found error on
> com.ctc.wstx.exc.WstxEOFException.  I have included the
> org.codehaus.woodstox/woodstox-core-asl in my POM and made sure the osgi
> bundle imports the com.ctc.wstx.exc package, but for some reason it can not
> work out this dependency.
>

That would be the ideal case to add an onException with that specify
exception type.
But yeah OSGi can be a beast to tame.

You could possible attach an <onWhen> predicate to the <onException>
and then test whether the exception class name is
Maybe something a like.

<onWhen>
   <simple>${exception.getClass().getSimpleName()} ==
'WstxEOFException'</simple>
</onWhen>

Instead of the simple you can also use use a pojo, that returns a
boolean, and then just use Exception as parameter.
Then you dont have any import for woodstock. And can check the class
name using String naming.




> Am I doing something obvious improperly?  Is there a different method I
> should go about trying to trap route errors?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Trapping-Errors-Help-tp5633932p5633932.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/