Bug 4989 - NPE in TransformerFactory.newInstance() when jaxp.properties is present.
Summary: NPE in TransformerFactory.newInstance() when jaxp.properties is present.
Status: NEW
Alias: None
Product: XmlCommons - Now in JIRA
Classification: Unclassified
Component: JAXP (show other bugs)
Version: 1.x
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---
Assignee: Commons Developers Mailing List
URL:
Keywords: APIBug
Depends on:
Blocks:
 
Reported: 2001-11-20 15:25 UTC by Steve
Modified: 2009-06-10 13:26 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 
exceptions:
javax.xml.transform.TransformerFactoryConfigurationError: Provider null could no
t be instantiated: java.lang.NullPointerException
        at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory
.java:145)
        at testtrans.main(testtrans.java:13)

Cause Exception:
java.lang.NullPointerException
        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
.java:139)
        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)
    {
        try
        {
            TransformerFactory tFactory = TransformerFactory.newInstance();
        }
        catch (TransformerFactoryConfigurationError e)
        {
            e.printStackTrace();

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


javax.xml.transform.FactoryFinder.find() is not checking for a null 
property value.  (line 186 in 2.2.D13) and is passing null to 
FactoryFinder.newInstance.
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
properties.
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.

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