jQuery in Action, 2nd edition*
The moose likes XML and Related Technologies and the fly likes Writing XML File - Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Writing XML File - Null Pointer Exception" Watch "Writing XML File - Null Pointer Exception" New topic
Author

Writing XML File - Null Pointer Exception

Anbarasu Selvaraj
Greenhorn

Joined: Mar 07, 2006
Posts: 21
Hi Friends,

At the time of writing xml file i am receiving the following message

javax.xml.transform.TransformerException: java.lang.NullPointerException
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at DisplayAppointments.<init>(DisplayAppointments.java:496)
at DisplayAppointments.main(DisplayAppointments.java:567)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.sun.org.apache.xml.internal.serializer.ToUnknownStream.characters(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(Unknown Source)
... 13 more
---------

The java code is

DOMSource source = new DOMSource(document);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(source, new StreamResult(new FileOutputStream(file)));

At the time of processing the third line it's give the above error.

Please advice me.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

My advice is to see whether the "file" variable is null.
 
Don't get me started about those stupid light bulbs.
 
subject: Writing XML File - Null Pointer Exception
 
Similar Threads
plz, stange problem when transfrom document to xml file with jaxp
Writing XML File via Java Program
a stange problem when transform a document to xml file?plz
XML on the fly using servlets
Problem saving XML doc due to NoSuchMethodError...