0

We are using a web service which throws 3 types of custom web service faults i.e. ServiceException, ConnectionException and InvalidDataException.

Along with these catch blocks, we have also put in the catch block for RemoteAccessException which is the spring's runtime exception.

catch (org.springframework.remoting.RemoteAccessException remoteAccessExc) {
}

While testing the above listed custom exceptions, we found that all these 3 types of exceptions are not getting catched in their respective catch blocks. Instead all gets catched in the last catch block which is the RemoteAccessException. We found during debugging the exception object of soap fault which is of type org.springframework.remoting.jaxws.JaxWsSoapFaultException that the service is throwing the correct faults.

My concern is why these faults are not falling into their own catch blocks. The service itself tells us to handle these exceptions while placing the service call.

When I hit the service through proxy java client, the faults fall correctly into their respective blocks. If there would have been a problem with POJO's then they shouldn't have worked in this case also. But they are working in this case(when hit through java proxy client) which means no problem in POJOs.

We are using spring-2.5.6.jar.

John Saunders
  • 160,644
  • 26
  • 247
  • 397

1 Answers1

0

Since you are keeping different catch blocks and the fault object is getting overridden, do the following:

Check whether the fault object is null or not in each catch block, so that when the fault is thrown, it won't get overridden in any other catch block. This is because you put the not null check at every entry of catch block.

try{
    //////
}Catch(IllegalArgumentException e){
    create fault object;
    throw fault;    
}
Catch(Exception e){
    ///check whether fault object is not null

    if(fault!=null){
    throw fault;
}else{
    ///another fault object 
    throw fault1;
}
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • I think you did not understand the problem stmt. My problem is why the exception not falling into their right catch blocks. We do not want to do any hack by handling it in the generic exception block. Hope this help to understand the problem. Why the fault is not being handled properly. – Gagan Arora Sep 26 '12 at 05:32