You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/09/18 20:01:26 UTC

DO NOT REPLY [Bug 23252] - org.apache.xml.serializer.Utils throws NullPointerException

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=23252>.
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=23252

org.apache.xml.serializer.Utils throws NullPointerException





------- Additional Comments From minchau@ca.ibm.com  2003-09-18 18:01 -------
Hi Erik,
If the class name is null you will get a null pointer exception.
If the class name is not null, but can't be loaded you will get a 
ClassNotFoundException.  But when either of these happen I don't understand how 
one can get to the put() because an exception will be thrown.

If the user specified content-handler doesn't exit then one of these would 
happen everytime. But what else should happen given that the custom 
ContentHandler cannot be loaded? I don't think it can recover.

By the way, when looking into this problem I see that 
org.apache.xml.serializer.Utils has changed in the current CVS as the line
you point to has moved. The code currently looks like this:
------------------------------------------------
    static Class ClassForName(String classname) throws ClassNotFoundException
    {
        Class c;
        // the first time the next line runs will reference
        // CacheHolder, causing the class to load and create the
        // Hashtable.
        Object o = CacheHolder.cache.get(classname);
        if (o == null)
        {
            // class was not in the cache, so try to load it
            c = Class.forName(classname);
            // if the class is not found we will have thrown a
            // ClassNotFoundException on the statement above
            
            // if we get here c is not null
            CacheHolder.cache.put(classname, c);
        }
        else
        {
            c = (Class)o;
        }
        return c;
    }
---------------------------------------------
The CacheHolder.cache.put(classname,c); is now on line 105, not 110 so I think 
your code is not the most current in CVS. If the Class.forname(classname) fails 
on line 105 then I don't see how we ever get to line 110 because it should 
throw a ClassNotFoundException and never get to the put(classname,c) with a 
null for c.

But with the code in the current CVS, Utils.ClassForName(classname) is never 
called. A developer has changed some of the class loading code that used to 
call this method. When I edited the output_xml.properties file and changed the 
content-handler property to point to a non-existant 
class "ThisClassDoesNotExist" I got this exception traceback:

java.lang.ClassNotFoundException: ThisClassDoesNotExist
	at java.net.URLClassLoader.findClass(URLClassLoader.java:240)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:516)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:441)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:448)
	at org.apache.xml.utils.ObjectFactory.findProviderClass
(ObjectFactory.java:387)
	at org.apache.xml.serializer.SerializerFactory.getSerializer
(SerializerFactory.java:124)
	at 
org.apache.xalan.transformer.TransformerImpl.createSerializationHandler
(TransformerImpl.java:1083)
	at 
org.apache.xalan.transformer.TransformerImpl.createSerializationHandler
(TransformerImpl.java:977)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:1172)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:1155)
	at org.apache.xalan.xslt.Process.main(Process.java:1026)


So to persue this bug please upgrade your code and confirm that you get a 
similar traceback. Otherwise please provide more information.


What behavior would you suggest? It is my presumption that you are looking for 
a more user friendly message as there isn't much to be done when a user 
specified content-handler doesn't exit, right?

Regards,
Brian Minchau