2012-04-17 116 views
2

我最近从骡2.2.1切换到骡子3.X骡子3 web服务不会返回堆栈跟踪

这样做的主旨是骡子3不返回堆栈跟踪,但骡子2呢,我怎么复制骡2的行为?

更多细节:

一些Web服务被包裹在一个try-catch,我们抛出ServiceException

@WebFault(name = "ServiceException") 
    public class ServiceException extends Exception { 
    private static final long serialVersionUID = 1L; 
    private Integer errorNumber; 

public ServiceException(Exception e, User user) { 
    super(makeMessage(e)); 
    LoggingDao.logException(this.getMessage(), e.toString()); 
    this.setStackTrace(e.getStackTrace()); 
    this.errorNumber = LoggingDao.getLogId(); 
} ... etc 

当我们捕捉到了异常与堆栈跟踪返回给Web的目标服务调用者,通过LoggingDao记录堆栈跟踪的方式,但Web服务不会返回它。

沿抛出一个MuleException将覆盖堆栈跟踪并返回

<soap:Fault> 
    <faultcode>soap:Server</faultcode> 
    <faultstring>Component that caused exception is: org.mule.component.DefaultJavaComponent component for: SedaService{...}. Message payload is of type: Object[]</faultstring> 
    </soap:Fault> 

我将如何去在骡子3.X

附注:返回堆栈跟踪我们跳进DefaultComponentLifecycleAdapter.java路上某处 我使用的是Mule 3.0.1,它似乎与我上面提供的链接不兼容。

也从:http://www.mulesoft.org/documentation/display/MULE3USER/Error+Handling

如果流动交换模式是请求 - 响应,不同的消息被返回到已经被执行之后调用者。该消息具有org.mule.transport.NullPayload作为其有效内容,并且exceptionPayload属性设置为以下内容:org.mule.api.ExceptionPayload。 < 前面提到的是什么给我带来麻烦?

从骡子2骡子-config.xml文件是在问候的交换模式不是“请求 - 响应”

回答

2

有人告诉我,这是骡子3一个已知的问题不同。 X < 3.2 的解决方案是通过
托马斯布洛赫姆

public class CustomSoapFaultOutInterceptor extends AbstractSoapInterceptor { 
    private static final Log logger = LogFactory.getLog(CustomSoapFaultOutInterceptor.class); 

public CustomSoapFaultOutInterceptor() { 
     super(Phase.MARSHAL); 
     getAfter().add(Soap11FaultOutInterceptor.class.getName()); 
    } 
    @Override 
    public void handleMessage(SoapMessage message) throws Fault { 
     Fault fault = (Fault) message.getContent(Exception.class); 
     logger.error(fault.getMessage(), fault); 
    //delete the Mule Exception to have the one throw by the component in the SoapMessage 
     Throwable t = getOriginalCause(fault.getCause()); 
     fault.setMessage(t.getMessage()); 
    } 
    private Throwable getOriginalCause(Throwable t) { 
     if (t.getCause() == null || t.getCause().equals(t)) 
      return t; 
     else 
      return getOriginalCause(t.getCause()); 
    } 
} 

//And then this into mule-config. 
<cxf:jaxws-service> 
    <cxf:outFaultInterceptors> 
     <spring:bean class="is.tr.mule.interceptor.CustomSoapFaultOutInterceptor"/> 
    </cxf:outFaultInterceptors> 
</cxf:jaxws-service> 
写一个OutFault拦截 代码