java.lang.ClassCastException When Getting a javax.xml.transform.TransformerFactory Instance (Doc ID 225814.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle XML Developers Kit - Version 8.1.7.4 and later
Information in this document applies to any platform.
***Checked for relevance on 12-Apr-2013***

Symptoms

Consider the following JAXP code

import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.dom.*;
import org.w3c.dom.Node;


public class TestTransform {
public static void main(String[] args)
{

System.setProperty("javax.xml.transform.TransformerFactory", "oracle.xml.jaxp.JXTransformer");
try {
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer serializer = tfactory.newTransformer();
}
catch (Exception e) {
e.printStackTrace();
}
System.exit(0);
}
}


When executing this code, the following error occurs:

> javac TestTransform.java
> java TestTransform

Exception in thread "main" javax.xml.transform.TransformerFactoryConfigurationError: Provider oracle.xml.jaxp.JXTransformer not found
at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory.java:100)
at TestTransform.main(TestTransform.java:13)

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms