Error with TransformerFactory.newInstance() in Java code.

Error with TransformerFactory.newInstance() in Java code.

book

Article ID: KB0088145

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks -
Not Applicable -

Description

Resolution:
Abstract:
==========
Error with TransformerFactory.newInstance() in Java code.


Description:
==========
TransformerFactory factory=TransformerFactory.newInstance();

or:

SAXTransformerFactory saxTransformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();


Environment:
==========
TIBCO ActiveMatrix BusinessWorks 5.9.3 and above.


Symptoms:
==========
While executing [invoke] encountered [java.lang.NoClassDefFoundError].

or:

java.lang.ClassCastException: com.tibco.xml.parsers.xmlfactories.TransformerFactory incompatible with javax.xml.transform.sax.SAXTransformerFactory .


Cause:
==========
The class is not set correctly with javax.xml.transform.TransformerFactory .


Resolution:
==========
Add:

System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");

or:

System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");

into the Java code before:

TransformerFactory.newInstance();

Other possible settings:

System.setProperty("javax.xml.transform.TransformerFactory", "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");

If you are testing in Designer, you will need to restart Designer after changes are made.


Issue/Introduction

Error with TransformerFactory.newInstance() in Java code.