Discussion:
[XOM-interest] Possible bug in build(String systemID) where systemID points to a resource within a jar file
Daniel Lowe
2009-10-26 13:42:33 UTC
Permalink
The problem I am encountering is introduced somewhere between revision
1.82 of Builder.java (this corresponds to XOM-1.1) and 1.86 (this
corresponds to XOM-1.2b1) with my hunch being that the cause of the
problem in the change to canonicalizeURL in 1.86.

The error is below:
C:\My Documents\workspace\xomTest\target>java -jar
xomTest-0.0.1-SNAPSHOT-jar-with-dependencies.jar
Exception in thread "main" java.net.MalformedURLException: invalid url:
//file:/C:/My%20Documents/workspace/xomTest/target/xomTest-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/foo/foo.xml
(java.net.MalformedURLException: no protocol:
//file:/C:/My%20Documents/workspace/xomTest/target/xomTest-0.0.1-SNAPSHOT-jar-with-dependencies.jar)

encies.jar)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrent
Entity(Unknown Source)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(
Unknown Source)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDocumen
tEntity(Unknown Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.setInp
utSource(Unknown Source)
at
com.sun.org.apache.xerces.internal.parsers.DTDConfiguration.parse(Unk
nown Source)
at
com.sun.org.apache.xerces.internal.parsers.DTDConfiguration.parse(Unk
nown Source)
at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So
urce)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Un
known Source)
at nu.xom.Builder.build(Unknown Source)
at nu.xom.Builder.build(Unknown Source)
at foo.App.openFile(App.java:27)
at foo.App.main(App.java:20)

This occurs when doing new Builder().build(u.toString()); where u is a
URL pointing to a file within the jar that the program is running from.
The exact same code works from within my IDE, when the resource has not
yet been placed in a jar.

If you would like to see my test code you can download it from:
http://senduit.com/8f7faf

To reiterate this error only occurs on Xom1.2beta and later; the code
works fine on Xom-1.1.

Thanks for your help,

Daniel
Timo Boehme
2009-10-26 15:37:43 UTC
Permalink
This problem was already discussed 4 weeks ago. Please search the
archive for "Canonicalization does not handle URI correctly".
Post by Daniel Lowe
The problem I am encountering is introduced somewhere between revision
1.82 of Builder.java (this corresponds to XOM-1.1) and 1.86 (this
corresponds to XOM-1.2b1) with my hunch being that the cause of the
problem in the change to canonicalizeURL in 1.86.
...
--Timo

Timo Boehme
OntoChem GmbH
H.-Damerow-Str. 4
06120 Halle/Saale
T: +49 345 4780472
F: +49 345 4780471
timo.boehme at ontochem.com

_____________________________________________________________________

OntoChem GmbH
Gesch?ftsf?hrer: Dr. Lutz Weber
Sitz: Halle / Saale
Registergericht: Stendal
Registernummer: HRB 215461
_____________________________________________________________________
Elliotte Rusty Harold
2009-10-27 11:41:30 UTC
Permalink
See here:

http://lists.ibiblio.org/pipermail/xom-interest/2009-September/004016.html

I suppose if there's a lot of demand for using jar URLs, I can
consider it if (and only if) supporting Sun's non-conformant URls
doesn't cause any downstream problems.
--
Elliotte Rusty Harold
elharo at ibiblio.org
Daniel Lowe
2009-10-27 14:01:32 UTC
Permalink
That would be appreciated although I will investigate replacing the
offending code with an alternative method for loading the XML file from
the jar.
I don't think:
ClassLoader l = getClass().getClassLoader();
URL u = l.getResource(resource);
Document d = new Builder().build(u.toString());
where resource is the name of a file and URL is a java.net.URL is a
particularly odd way of getting at a resource so I could imagine others
may also run into this especially as it works in XOM 1.1

Daniel
Post by Elliotte Rusty Harold
http://lists.ibiblio.org/pipermail/xom-interest/2009-September/004016.html
I suppose if there's a lot of demand for using jar URLs, I can
consider it if (and only if) supporting Sun's non-conformant URls
doesn't cause any downstream problems.
Loading...