[jdom-interest] SaxBuilder error: root element missing

Emmanuel Gilmont emmanuel at isc.be
Wed Oct 8 06:18:38 PDT 2003


Hi all,

Here is my problem:

When I try to parse an xml document using the 
SaxBuilder.build(|java.io.File file) method, there is no problem.

When I put the same file inside a jar file and try to parse it using 
|the SaxBuilder.build(|java.net.URL url)|, I got an error saying  the 
root element is missing in the document (full message at the end).

Code sample (say the file name is tpc.xml) :
-------------------------------------------
//- this works
SaxBuilder sb = new SaxBuilder();
Document doc = sb.build("c:/tpc.xml");

//- this doesn't work
SaxBuilder sb = new SaxBuilder();
Document doc = sb.build(getClass().getResource("/ressources/tpc.xml"));

Does anyone have any idea?

Thanks,
Emmanuel

---------------------------------------------

org.jdom.input.JDOMParseException: Error on line 1 of document 
jar:file:/C:/perso/lib/tpc_1.0.jar!/ressources/tpc.xml: ElÚment racine 
de document manquant.
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:377)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:724)
        at 
org.egilmont.commons.xml.TreeSearcher.setDocumentFromUrl(Unknown Source)
        at org.egilmont.commons.io.ConfigFile.<init>(Unknown Source)
        at org.egilmont.commons.io.ConfigFile.checkConfigFile(Unknown 
Source)
        at org.egilmont.tpc.TortoiseProfileChanger.readConfig(Unknown 
Source)
        at org.egilmont.tpc.TortoiseProfileChanger.main(Unknown Source)
Caused by: org.xml.sax.SAXParseException: ElÚment racine de document 
manquant.
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3339)
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3327)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:635)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
        at 
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:370)
        ... 6 more
Caused by: org.xml.sax.SAXParseException: ElÚment racine de document 
manquant.
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3339)
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3327)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:635)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
        at 
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:370)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:724)
        at 
org.egilmont.commons.xml.TreeSearcher.setDocumentFromUrl(Unknown Source)
        at org.egilmont.commons.io.ConfigFile.<init>(Unknown Source)
        at org.egilmont.commons.io.ConfigFile.checkConfigFile(Unknown 
Source)
        at org.egilmont.tpc.TortoiseProfileChanger.readConfig(Unknown 
Source)
        at org.egilmont.tpc.TortoiseProfileChanger.main(Unknown Source)
Caused by: org.xml.sax.SAXParseException: ElÚment racine de document 
manquant.
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3339)
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3327)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:635)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
        at 
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:370)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:724)
        at 
org.egilmont.commons.xml.TreeSearcher.setDocumentFromUrl(Unknown Source)
        at org.egilmont.commons.io.ConfigFile.<init>(Unknown Source)
        at org.egilmont.commons.io.ConfigFile.checkConfigFile(Unknown 
Source)
        at org.egilmont.tpc.TortoiseProfileChanger.readConfig(Unknown 
Source)
        at org.egilmont.tpc.TortoiseProfileChanger.main(Unknown Source)
||





More information about the jdom-interest mailing list