Forum Home » Enterprise Products » Fuse ESB Enterprise

Thread: Camel doesn't recognize faults as exceptions

 
This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Mar 18, 2013 6:48 AM Last Post By: njiang Threads: [ Previous | Next ]
alexander.durnev

Posts: 11
Registered: 01/31/13
Camel doesn't recognize faults as exceptions
Posted: Mar 1, 2013 8:33 AM
 
  Click to reply to this thread Reply
I've encountered a very strange problem with Fuse ESB 7.1.0: when a cxf endpoint produces a fault, then this fault doesn't look like an exception, so I can't process it using doCatch construction.
The cxf endpoint is defined as follows:

<cxf:cxfEndpoint id="cxf-ep" address="${ws.url}"
serviceClass="MyServiceClass">
<cxf:properties>
<entry key="dataFormat" value="POJO" />
</cxf:properties>
</cxf:cxfEndpoint>


And here is a short code snippet where I expect an exception:

<doTry>
<to uri="cxf:bean:cxf-ep" />
<doCatch>
<exception>org.apache.cxf.interceptor.Fault</exception>
<handled>
<constant>true</constant>
</handled>
<to
uri="log:exceptions?multiline=true&amp;showCaughtException=true&amp;showStackTrace=true&amp;showBody=true&amp;showProperties=true&amp;showHeaders=true&amp;level=ERROR" />
</doCatch>
</doTry>

I've tried to add handleFault="true" attribute to both a camel context and a route, but without success.
A bundle with a similar parameters and routes has worked as expected on Fuse ESB/ServiceMix 4.4.1, so it looks like a regression or maybe something has changed in camel in the new release?

Another interesting moment is that when a web server is not available, then camel produces org.apache.cxf.interceptor.Fault, so it can't be handled as an exception!

Edited by: alexander.durnev on Mar 1, 2013 8:39 AM
alexander.durnev

Posts: 11
Registered: 01/31/13
Re: Camel doesn't recognize faults as exceptions
Posted: Mar 4, 2013 11:44 AM   in response to: alexander.durnev in response to: alexander.durnev
 
  Click to reply to this thread Reply
I use a cxf jaxws client bean as a workaround currently.
njiang

Posts: 572
Registered: 09/17/07
Re: Camel doesn't recognize faults as exceptions
Posted: Mar 5, 2013 12:50 PM   in response to: alexander.durnev in response to: alexander.durnev
 
  Click to reply to this thread Reply
It is strange, I just wrote an unit test but cannot reproduce the error.
Can you paste the full camel route ?

The change of camel-cxf recently is to honor the Message Exchange Pattern. But I don't think it could cause the trouble that you meet.
alexander.durnev

Posts: 11
Registered: 01/31/13
Re: Camel doesn't recognize faults as exceptions
Posted: Mar 11, 2013 8:06 AM   in response to: njiang in response to: njiang
 
  Click to reply to this thread Reply
My camel context looks as following (I've simplified it):


<camelContext id="my-context" xmlns="http://camel.apache.org/schema/spring"
trace="false" autoStartup="true" handleFault="true">
<propertyPlaceholder id="properties" location="ref:configProps" />
<route id="main">
<from uri="jetty:http://0.0.0.0:{{ws.port}}/{{ws.path}}" />

<setBody>
<groovy>
<!-- some logic, constructs a request pojo -->
.....
</groovy>
</setBody>
<removeHeaders pattern="*" />
<setHeader headerName="operationName">
<constant>myOperation</constant>
</setHeader>
<doTry>
<to uri="cxf:bean:cxf-ep"/>
<doCatch>
<exception>java.lang.Throwable</exception>
<handled>
<constant>true</constant>
</handled>
<to
uri="log:exceptions?multiline=true&amp;showCaughtException=true&amp;showStackTrace=true&amp;showBody=true&amp;showProperties=true&amp;showHeaders=true&amp;level=ERROR" />
<stop/>
</doCatch>
</doTry>

<to uri="direct:secondRoute" />
</route>



I've performed the following steps:
  1. I've changed targeted web service parameters, so it references on the non-existent server;
  2. I've performed a request to the bundle via http;
  3. I see the trace back with "Connection refused" message in the log file, but with WARN level (!!!), so it has logged outside of my bundle;
  4. I don't see a log entry with ERROR level that I've expected;
  5. I see that the route wasn't stopped and a secondRoute was executed, so I'm absolutely sure that the doCatch instruction wasn't executed.
njiang

Posts: 572
Registered: 09/17/07
Re: Camel doesn't recognize faults as exceptions
Posted: Mar 18, 2013 6:48 AM   in response to: alexander.durnev in response to: alexander.durnev
 
  Click to reply to this thread Reply
Hi,

I wrote some simple test to reproduce the error, but I cannot reproduce it.
From the route and you description, I cannot tell anything wrong.
Can you just try to send a simple test case for us to reproduce the error?

Regards,

Willem