Error: "[java.lang.ClassCastException] : [com.tibco.xml.parsers.xmlfactories.TransformerFactory cannot be cast to javax.xml.transform.sax.SAXTransformerFactory" while migrating Java activity from BW5.9 to BW5.11.

Error: "[java.lang.ClassCastException] : [com.tibco.xml.parsers.xmlfactories.TransformerFactory cannot be cast to javax.xml.transform.sax.SAXTransformerFactory" while migrating Java activity from BW5.9 to BW5.11.

book

Article ID: KB0093077

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks -
Not Applicable -

Description

Description:
Test in Designer with Java code,  "System.out.println(System.getProperty("javax.xml.transform.TransformerFactory"));". You should be able to see "com.tibco.xml.parsers.xmlfactories.TransformerFactory" in BW5.11, but "null" in BW5.9. That is, in BW5.11, "javax.xml.transform.TransformerFactory" is set with the value "com.tibco.xml.parsers.xmlfactories.TransformerFactory" by default. But BW5.9 does not.


Issue/Introduction

Error: "[java.lang.ClassCastException] : [com.tibco.xml.parsers.xmlfactories.TransformerFactory cannot be cast to javax.xml.transform.sax.SAXTransformerFactory" while migrating Java activity from BW5.9 to BW5.11.

Resolution

If you need an instance of the "SAXTransformerFactory" class, use setProperty() to specify another compatible "TransformerFactoryImpl" to override the TIBCO one which has not fully implemented the SAXTransformerFactory.  Example, configure by Java code: System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
 

TIBCO only relies on SAXParserFactory more than SAXTransformerFactory because in both designer.tra files of BW5.9 and BW5.11, at the end of the file you will see 

 

 {

  java.property.javax.xml.parsers.SAXParserFactory org.apache.xerces.jaxp.SAXParserFactoryImpl
  java.property.javax.xml.parsers.DocumentBuilderFactory org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
  }

Additional Information

KB 36614, SR 494776