Custom Error Handling with Oracle Service Bus


An Enterprise Service Bus is becoming a core component in today’s Service oriented architectures.

Whenever we integrate multiple applications, One common problem we run into is that, in case of an exception being thrown by a

service, the end client receives an “Internal BEA error “instead of the actual exception being

thrown by the service.

This paper tries to explain why this happens and provide a solution approach on how meaningful custom

messages can be presented to the end SOAP client.

The fundamental reason for this is because of the way, Oracle Service Bus populates its context variables

such as $body and $fault when an exception is risen. Details regarding context variables can be found at

http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/context.html#wp1051267

but at a high level, when an exception is thrown by the backend service, the exception is put in the

$body variable and a predefined System message and error code is put in the $fault variable. The web

service client gets a SOAP fault which is populated by the content in $fault and that information is of no

help for any troubleshooting.

In order to provide custom error messages to the end client, we implemented the following approach –

1. Configure a Service Error Handler for the Proxy

2. Create two proxies – one a generic proxy to the business service and another client specific

proxy that calls the generic proxy

3. Leverage the Reply with Failure construct that populates $fault with $body

Details regarding the various error codes generated by the service bus can be found at

http://edocs.bea.com/alsb/docs30/javadoc/constant-values.html. The error codes that are most

relevant are

Error Code Explanation

BEA-380001 Service up, but an application exception

BEA-38002 Service unavailable

Other ones Service up, but infrastructure related issue

With the above information on hand, in the Service Error Handler of the generic proxy, we used the

if-then –else , XQuery functions and raise Error constructs provided by the service bus to throw the

appropriate user friendly exception.

  • $fault can be interrogated using ” fn:starts-with($fault/ctx:errorCode/text(),”BEA-380002″)
  • $body can be interrogated for application error using fn:starts-with($body/soapenv:

Fault/detail/error/text(),”ServiceProcessor.getData(): Invalid Data Sent “)

  • Raise Error using a custom error code with a custom error message

Thus, in a nutshell, Generic Proxy identifies if it is a System exception or Application exception

and rethrows a user friendly exception. The key point is that when a custom exception is

thrown from the Generic proxy, $body contains the user friendly message and $fault contains

the custom error code.

The client specific proxy, in its service error handler uses the if-then-else construct

  • interrogates $body using fn:starts-with($body/soap-env:Fault/faultString,”BEA”). If it does, it

implies that this is a system error and it raises a user friendly system error

  • Else, it replies with failure.

With reply on failure construct, Oracle Service Bus populates $fault with $body and thus enables the

web service client to see the actual error message from the SOAP Fault.

Conclusion:

By implementing the approach presented above, readers can customize the error messages to their

end SOAP clients and hide the arcane Oracle Service Bus errors.

References:

1. Oracle Service Bus User Guide –

http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/userguide/index.html

Update 09/06/2015:

I think it might be useful for you all to go through these articles regarding Error Propagation.

Oracle Support Document 860492.1 (How to Propagate a SOAP Fault from a Backend System to a Client Using Oracle Service Bus?) can be found at: https://support.oracle.com/epmos/faces/DocumentDisplay?id=860492.1

Oracle Support Document 1307564.1 (How to Pass or Propagate Endpoint Exceptions to the Calling Proxy – Tips for Error Handling in OSB) can be found at: https://support.oracle.com/epmos/faces/DocumentDisplay?id=1307564.1

Oracle Support Document 1129390.1 (How to Propagate HTTP Response Code, e.g. HTTP Response 304, From Back-End to Client in OSB) can be found at: https://support.oracle.com/epmos/faces/DocumentDisplay?id=1129390.1

2 comments

  1. java.lang.Exception: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: oracle.fabric.common.PolicyEnforcementException: no transaction to be exported! at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:575) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:381) at oracle.sysman.emas.view.wsmgt.WSView.invokeOperation(WSView.java:298) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.el.parser.AstValue.invoke(AstValue.java:157) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283) at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53) at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1259) at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:90) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:309) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:94) at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:97) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:90) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:309) at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:94) at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:91) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:698) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:285) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:97) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420) at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157) at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.help.web.rich.OHWFilter.doFilter(Unknown Source) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.emSDK.license.LicenseFilter.doFilter(LicenseFilter.java:101) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.emas.fwk.MASConnectionFilter.doFilter(MASConnectionFilter.java:41) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:159) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.AuditServletFilter.doFilter(AuditServletFilter.java:179) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.EMRepLoginFilter.doFilter(EMRepLoginFilter.java:203) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.core.app.perf.PerfFilter.doFilter(PerfFilter.java:141) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.sysman.eml.app.ContextInitFilter.doFilter(ContextInitFilter.java:542) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:330) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3684) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) Caused by: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: oracle.fabric.common.PolicyEnforcementException: no transaction to be exported! at oracle.sysman.emSDK.webservices.wsdlapi.dispatch.DispatchUtil.invoke(DispatchUtil.java:260) at oracle.sysman.emSDK.webservices.wsdlparser.OperationInfoImpl.invokeWithDispatch(OperationInfoImpl.java:985) at oracle.sysman.emas.model.wsmgt.PortName.invokeOperation(PortName.java:729) at oracle.sysman.emas.model.wsmgt.WSTestModel.invokeOperation(WSTestModel.java:569) … 69 more Caused by: javax.xml.ws.WebServiceException: oracle.fabric.common.PolicyEnforcementException: no transaction to be exported! at oracle.j2ee.ws.client.jaxws.DispatchImpl.invoke(DispatchImpl.java:784) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.synchronousInvocationWithRetry(OracleDispatchImpl.java:234) at oracle.j2ee.ws.client.jaxws.OracleDispatchImpl.invoke(OracleDispatchImpl.java:105) at oracle.sysman.emSDK.webservices.wsdlapi.dispatch.DispatchUtil.invoke(DispatchUtil.java:256) … 72 more Caused by: oracle.fabric.common.PolicyEnforcementException: no transaction to be exported! at oracle.integration.platform.common.InterceptorChainImpl.createPolicyEnforcementException(InterceptorChainImpl.java:163) at oracle.integration.platform.common.InterceptorChainImpl.processRequest(InterceptorChainImpl.java:99) at oracle.integration.platform.common.mgmt.InterceptorChainManager.processRequest(InterceptorChainManager.java:232) at oracle.j2ee.ws.client.mgmt.runtime.SuperClientInterceptorPipeline.handleRequest(SuperClientInterceptorPipeline.java:96) at oracle.j2ee.ws.client.jaxws.DispatchImpl.handleRequest(DispatchImpl.java:571) at oracle.j2ee.ws.client.jaxws.DispatchImpl.handleRequest(DispatchImpl.java:549) at oracle.j2ee.ws.client.jaxws.DispatchImpl.invoke(DispatchImpl.java:736) … 75 more Caused by: javax.xml.ws.WebServiceException: no transaction to be exported! at weblogic.wsee.wstx.wsat.tube.WSATClientHelper.doHandleRequest(WSATClientHelper.java:40) at oracle.j2ee.ws.client.transaction.OutboundWSATDelegate.doRequest(OutboundWSATDelegate.java:26) at oracle.j2ee.ws.client.transaction.ClientWSATInterceptor.processRequest(ClientWSATInterceptor.java:134) at oracle.integration.platform.common.InterceptorChainImpl$1.run(InterceptorChainImpl.java:173) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:396) at oracle.integration.platform.common.InterceptorChainImpl.processRequestAsSubject(InterceptorChainImpl.java:171) at oracle.integration.platform.common.InterceptorChainImpl.processRequest(InterceptorChainImpl.java:88) … 80 more

    This is the error I got when doing the testing with the deployed project ,it is repeated with all the DB operations like select ,insert ,delete ,update while testing ….
    Cannot understand what it is about …
    Can any body help me out with this pls to know the solution please
    its urgent ,pls help me …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s