You are catching the Exception and then just printing a stack trace.  You 
aren’t then throwing something from your handleMessage.   The handleFault 
method is called if and exception /fault is thrown from the handleMessage 
method.  If nothing is thrown from there, CXF assumes everything has processed 
normally and continues.

Dan


On Jan 15, 2014, at 5:57 AM, nikosdim <[email protected]> wrote:

> Hi
> 
> I have an inbound interceptor that performs some actions before invoking my
> webservice. In my interceptor I call method from classes that I instantiate
> on runtime with Class.forName(cls);
> 
> I am currently testing what happens when I give invalid class name in the
> cls variable and I noticed that despite the fact that ClassNotFoundException
> occurs (which I am catching) the method handleFault() is never called. 
> 
> Why is that happening? I've read that handleFault() is called when the
> process in the handleMessage is interrupted but what this exactly means?
> Isn't an Exception an interruption?
> 
> My code:
> 
> public class ESMAPISecurityInterceptor extends
>               AbstractPhaseInterceptor<Message> {
> 
>       public ESMAPISecurityInterceptor(String phase) {
>               super(phase);
>       }
> 
>       @Override
>       public void handleMessage(Message message) throws Fault {
>               try {
>                       Class<?> c = Class.forName("an.invalid.class.name");
>               } catch (ClassNotFoundException e) {
>                       e.printStackTrace();
>               }
>       }
> 
>       @Override
>       public void handleFault(Message message) {
>               System.out.println("Prints from handleFault()");
>       }
> }
> 
> Thanks
> 
> 
> 
> --
> View this message in context: 
> http://cxf.547215.n5.nabble.com/handleFault-method-not-called-when-exception-occurs-in-handleMessage-tp5738573.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to