Bug 4989

Summary: NPE in TransformerFactory.newInstance() when jaxp.properties is present.
Product: XmlCommons - Now in JIRA Reporter: Steve <se_johnson>
Component: JAXPAssignee: Commons Developers Mailing List <commons-dev>
Status: NEW ---    
Severity: normal Keywords: APIBug
Priority: P3    
Version: 1.x   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Steve 2001-11-20 15:25:57 UTC
If jaxp.properties is present in JAVA_HOME/jre/lib and it does not
contain a javax.xml.transform.TransformerFactory property,
when issuing TransformerFactory.newInstance, you get the following 
javax.xml.transform.TransformerFactoryConfigurationError: Provider null could no
t be instantiated: java.lang.NullPointerException
        at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory
        at testtrans.main(testtrans.java:13)

Cause Exception:
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:279)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
        at javax.xml.transform.FactoryFinder.newInstance(FactoryFinder.java:132)

        at javax.xml.transform.FactoryFinder.find(FactoryFinder.java:188)
        at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory
        at testtrans.main(testtrans.java:13) 

Test program for above:
import javax.xml.transform.*;

// Test program to product null pointer in TransformerFactory.newInstance().
// JAVA_HOME/jre/lib must contain a jaxp.properties file.
// The jaxp.properties must not contain a javax.xml.transform.TransformerFactory
// property.  An empty jaxp.properties file will do.
public class testtrans
    public static void main (String [] args)
            TransformerFactory tFactory = TransformerFactory.newInstance();
        catch (TransformerFactoryConfigurationError e)

            Exception ee = e.getException();
            if (ee != null)
                System.out.println("Cause Exception:");
        catch (Throwable t)

javax.xml.transform.FactoryFinder.find() is not checking for a null 
property value.  (line 186 in 2.2.D13) and is passing null to 
The find() code does have a catch for Exception, but newInstance() converts
the null pointer exception to a ConfigurationError which is derived
from Error not Exception.  ConfigurationError is not caught by find() and
Error is ultimately returned to user.

Error was discovered when trying to use jaxp.properties to set other
Comment 1 Edwin Goei 2002-01-16 19:04:01 UTC
Yup, it needs to be fixed.  But I believe there is a workaround so I will fix it 
later.  Thanks for the detailed bug report and simple program.

Comment 2 Mark Thomas 2009-06-10 13:26:23 UTC
Reset assignee so mails go to list.