DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4989>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4989

Null pointer in TransformerFactory.newInstance() when jaxp.properties is present.

           Summary: Null pointer in TransformerFactory.newInstance() when
                    jaxp.properties is present.
           Product: XalanJ2
           Version: 2.2.x
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: javax.xml
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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.

Reply via email to