Friday, June 14, 2013

Error While Throwing SOAPFaultException From Java Embedding to BPEL - "This class does not support SAAJ 1.1"

This post is valid for SOA 11.1.1.6.

Before looking at how to resolve "This class does not support SAAJ 1.1" error, here are some rules to consider while using java embedding activity in bpel.


  • BPEL 2.0 syntax to import a java class is -

<import location="com.oracle.bpel.client.BPELFault" importType="http://schemas.oracle.com/bpel/extension/java"/>
  • All custom jars must be added to the classpath and lib (SCA-INF/lib) folder of the soa project as shown in the image below.





  • Java embedding can only invoke static methods from the custom jars else you will see an error "failed to compile excelet" while deploying soa project. Make sure that the function that you are invoking from custom jar is static function.


  • BPEL understands only BPELFaults. Java exceptions must be caught within a java embedding try-catch block and inside catch block BPELFault needs to be raised like in the code excerpt below.

try {            
    String response = WebserviceHTTPClient.invoke(webserviceURL, operationName, 
                                            bodyContent);     
    addAuditTrailEntry(">>>>>>>> Response - "+response); 
} catch (Exception e){                          
    addAuditTrailEntry(">>>>>>>> Exception - "+ e.getMessage());      
    QName qName = new QName("http://schemas.oracle.com/bpel/extension", "remoteFault");      
     
    // create a new BPELFault exception      
    BPELFault bpelFault = new BPELFault(qName);      
     
    // set the details of the fault      
    bpelFault.setPart("code", "2001");      
    bpelFault.setPart("summary", "some error");      
    bpelFault.setPart("detail", e.getMessage());      
     
    // throw the fault      
    throw bpelFault;      
}


Now about how to resolve SAAJ version error. The solution is provided here but I am listing as a note for me as the scenario I encountered for this issue is slightly different -


Scenario - A custom jar method is invoked in java embedding which is throwing SOAPFaultException. Java embedding  catches the exception and try to build BPELFault. But the message retrieved from the exception caught shows - "This class does not support SAAJ 1.1" instead of the actual soap fault error message.

Resolution - Weblogic has a default SAAJ implementation in package weblogic.webservice.core.soap, that seems be causing this issue. Hence we need to override the properties to use a better implementation weblogic.xml.saaj  package. To override add this to your startWeblogic script and restart the server.

-Djavax.xml.soap.MessageFactory=weblogic.xml.saaj.MessageFactoryImpl

Earlier I have also encountered "There was no content-type header" message in java embedding catch block.  This was because the MimeHeader passed to build SOAPFault was null.

4 comments:

  1. Have tried with both bpel 1.1 & 2.0 but no luck..do you have sample code for this?

    ReplyDelete
  2. Wow, What an Outstanding post. I found this too much informatics. It is what I was seeking for. I would like to recommend you that please keep sharing such type of info.If possible, Thanks. battle axe

    ReplyDelete

Demystifying OIC, OCI and Oracle SOA CS

What is OIC (Oracle integration cloud), OCI (Oracle cloud infrastructure), and SOA cloud service and how they are different? - This has bee...