Resolver attempts to resolve XSDs from w3c.org site [rename] #253

Closed
opened 2025-07-03 20:33:20 +02:00 by dizzzz · 11 comments
dizzzz commented 2025-07-03 20:33:20 +02:00 (Migrated from github.com)

Hi Norm,

Thank you for your great work on the XML resolver!

Version: most recent 6.x (resolver + data)

I'd like to consult you on something..... I have integrated theresolver in some some junit tests, basically to explore how the APIs can be used.

It appears that there are significant performance differences between running these tests on my VDI (virtualized PC, Windows 10) and my build agent (Tests run in Java21 linux docker container, which runs on a Linux bamboo agent.)

There are only 4 tests, taking 0.25s on windows, and 131s (!) on docker. Leaving out the preparation/test code, this is the pseudo code:

Good old EntityResolver

final InputSource inputSource = resolver.getEntityResolver().resolveEntity(TestShared.XMLSIG_NS, TestShared.XMLSIG_NS);

For sure the Entity2Resolver

 final InputSource inputSource = resolver.getEntityResolver2().resolveEntity(TestShared.XMLSIG_NS, TestShared.XMLSIG_NS);

The LSResourceResolver

final LSInput lsInput = resolver.getLSResourceResolver().resolveResource(ResolverConstants.NATURE_XML_SCHEMA, TestShared.XMLSIG_NS, null, null, null);

And the internal API

final ResourceRequest resourceRequest = resolver.getRequest(TestShared.XMLSIG_NS, null);
final ResourceResponse resourceResponse = resolver.resolve(resourceRequest);

Also nicely integrated with a parser and validator, the performance is so off expectations.

Do you have an idea why the difference in speed is so significant? Any idea where I should start looking?

Hi Norm, Thank you for your great work on the XML resolver! Version: most recent 6.x (resolver + data) I'd like to consult you on something..... I have integrated theresolver in some some junit tests, basically to explore how the APIs can be used. It appears that there are significant performance differences between running these tests on my VDI (virtualized PC, Windows 10) and my build agent (Tests run in Java21 linux docker container, which runs on a Linux bamboo agent.) There are only 4 tests, taking 0.25s on windows, and 131s (!) on docker. Leaving out the preparation/test code, this is the pseudo code: Good old EntityResolver ```java final InputSource inputSource = resolver.getEntityResolver().resolveEntity(TestShared.XMLSIG_NS, TestShared.XMLSIG_NS); ``` For sure the Entity2Resolver ``` java final InputSource inputSource = resolver.getEntityResolver2().resolveEntity(TestShared.XMLSIG_NS, TestShared.XMLSIG_NS); ``` The LSResourceResolver ``` java final LSInput lsInput = resolver.getLSResourceResolver().resolveResource(ResolverConstants.NATURE_XML_SCHEMA, TestShared.XMLSIG_NS, null, null, null); ``` And the internal API ``` java final ResourceRequest resourceRequest = resolver.getRequest(TestShared.XMLSIG_NS, null); final ResourceResponse resourceResponse = resolver.resolve(resourceRequest); ``` Also nicely integrated with a parser and validator, the performance is so off expectations. Do you have an idea why the difference in speed is so significant? Any idea where I should start looking?
dizzzz commented 2025-07-03 20:38:57 +02:00 (Migrated from github.com)

A factor is that on my Windows PC there is an HTTP proxy defined which could be used to resolve schemas/dtds/entities; this ENV setting is not available on the build agent. This could in theory cause HTTP timeouts, but I have no proof of this. In the code snippets above only entities stored in the data jar are (attempted to be) resolved.

A factor is that on my Windows PC there is an HTTP proxy defined which could be used to resolve schemas/dtds/entities; this ENV setting is not available on the build agent. This could in theory cause HTTP timeouts, but I have no proof of this. In the code snippets above only entities stored in the data jar are (attempted to be) resolved.
dizzzz commented 2025-07-09 17:25:59 +02:00 (Migrated from github.com)

it looks like (checking with wireshark) still some calls are made to w3c.org.... firewalls do not allow...

Image
it looks like (checking with wireshark) still some calls are made to w3c.org.... firewalls do not allow... <img width="693" height="120" alt="Image" src="https://github.com/user-attachments/assets/7f40e405-e6e1-4ac0-8b22-f2edc99b2700" />
ndw commented 2025-07-09 17:31:27 +02:00 (Migrated from github.com)

Interesting. Have you enabled the MERGE_HTTPS property? I can't tell from your screenshot, are those attempts to use http or https?

It looks like the xmldsig issue may be a different bug. The manifest has a trailing # on the URI which may be causing the miss. I shall have to see if I can test that.

Interesting. Have you enabled the `MERGE_HTTPS` property? I can't tell from your screenshot, are those attempts to use `http` or `https`? It looks like the `xmldsig` issue may be a different bug. The manifest has a trailing `#` on the URI which may be causing the miss. I shall have to see if I can test that.
dizzzz commented 2025-07-10 09:45:52 +02:00 (Migrated from github.com)

thnx for responding. I did not (yet) switch on the 'merge' option.

I see similar delays for eg XMLschema.dtd; I enabled some logging:

the first and last logs lines come from my application, where I put a StopWatch directly around the call to the XMLresolver.

build	10-Jul-2025 07:36:08	07:36:08.629 [main] DEBUG myapp.lexicalstructure.DiyLSResourceResolver[resolve]:65 - Resolving systemId=http://www.w3.org/2001/XMLSchema.dtd publicId=-//W3C//DTD XMLSchema 200102//EN 

resolver:

error	10-Jul-2025 07:36:08	INFO: config: Prefer public: true
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Prefer property file: false
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Allow catalog PI: true
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Always resolve: false
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Parse RDDL: true
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: URI for system: true
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Merge http/https: true
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Mask jar URIs: true
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Catalog loader: org.xmlresolver.loaders.XmlLoader
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Classpath catalogs: true
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Archived catalogs: true
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Throw URI exceptions: false
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Class loader: jdk.internal.loader.ClassLoaders$AppClassLoader@5a07e868
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Logger class: org.xmlresolver.logging.SystemLogger
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Access external entity: all
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Access external document: all
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: XMLReader supplier: org.xmlresolver.XMLResolverConfiguration$$Lambda/0x00007fa19c4a8440@64a009e7
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Fix Windows system identifiers: false
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Default logger log level: warn
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Catalog: ./catalog.xml
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Catalog: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/catalog.xml
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger warn
error	10-Jul-2025 07:36:08	WARNING: request: resolveResource: XML: http://www.w3.org/2001/XMLSchema.dtd (baseURI: null, publicId: -//W3C//DTD XMLSchema 200102//EN)
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger warn
error	10-Jul-2025 07:36:08	WARNING: request: lookupEntity: http://www.w3.org/2001/XMLSchema.dtd (baseURI: null, publicId: -//W3C//DTD XMLSchema 200102//EN)
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger warn
error	10-Jul-2025 07:36:08	WARNING: error: Failed to load catalog: file:/usr/src/mymaven/myapp/catalog.xml: /usr/src/mymaven/myapp/catalog.xml (No such file or directory)
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger warn
error	10-Jul-2025 07:36:08	WARNING: error: Failed to load archived catalog: file:/usr/src/mymaven/myapp/catalog.xml: /usr/src/mymaven/myapp/catalog.xml (No such file or directory)
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Loaded catalog: file:/usr/src/mymaven/myapp/catalog.xml
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: config: Loaded catalog: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/catalog.xml
error	10-Jul-2025 07:36:08	Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info
error	10-Jul-2025 07:36:08	INFO: response: lookupEntity: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/www.w3.org/2001/XMLSchema.dtd

after some time of quiet-ness, my code logs:

build	10-Jul-2025 07:38:19	07:38:19.698 [main] DEBUG myapp.lexicalstructure.DiyLSResourceResolver[resolve]:76 - Succesfully resolved systemId=http://www.w3.org/2001/XMLSchema.dtd publicId=-//W3C//DTD XMLSchema 200102//EN  in 00:02:11.066.
thnx for responding. I did not (yet) switch on the 'merge' option. I see similar delays for eg XMLschema.dtd; I enabled some logging: the first and last logs lines come from my application, where I put a StopWatch directly around the call to the XMLresolver. ``` build 10-Jul-2025 07:36:08 07:36:08.629 [main] DEBUG myapp.lexicalstructure.DiyLSResourceResolver[resolve]:65 - Resolving systemId=http://www.w3.org/2001/XMLSchema.dtd publicId=-//W3C//DTD XMLSchema 200102//EN ``` resolver: ``` error 10-Jul-2025 07:36:08 INFO: config: Prefer public: true error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Prefer property file: false error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Allow catalog PI: true error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Always resolve: false error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Parse RDDL: true error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: URI for system: true error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Merge http/https: true error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Mask jar URIs: true error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Catalog loader: org.xmlresolver.loaders.XmlLoader error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Classpath catalogs: true error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Archived catalogs: true error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Throw URI exceptions: false error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Class loader: jdk.internal.loader.ClassLoaders$AppClassLoader@5a07e868 error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Logger class: org.xmlresolver.logging.SystemLogger error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Access external entity: all error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Access external document: all error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: XMLReader supplier: org.xmlresolver.XMLResolverConfiguration$$Lambda/0x00007fa19c4a8440@64a009e7 error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Fix Windows system identifiers: false error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Default logger log level: warn error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Catalog: ./catalog.xml error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Catalog: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/catalog.xml error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger warn error 10-Jul-2025 07:36:08 WARNING: request: resolveResource: XML: http://www.w3.org/2001/XMLSchema.dtd (baseURI: null, publicId: -//W3C//DTD XMLSchema 200102//EN) error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger warn error 10-Jul-2025 07:36:08 WARNING: request: lookupEntity: http://www.w3.org/2001/XMLSchema.dtd (baseURI: null, publicId: -//W3C//DTD XMLSchema 200102//EN) error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger warn error 10-Jul-2025 07:36:08 WARNING: error: Failed to load catalog: file:/usr/src/mymaven/myapp/catalog.xml: /usr/src/mymaven/myapp/catalog.xml (No such file or directory) error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger warn error 10-Jul-2025 07:36:08 WARNING: error: Failed to load archived catalog: file:/usr/src/mymaven/myapp/catalog.xml: /usr/src/mymaven/myapp/catalog.xml (No such file or directory) error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Loaded catalog: file:/usr/src/mymaven/myapp/catalog.xml error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: config: Loaded catalog: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/catalog.xml error 10-Jul-2025 07:36:08 Jul 10, 2025 7:36:08 AM org.xmlresolver.logging.SystemLogger info error 10-Jul-2025 07:36:08 INFO: response: lookupEntity: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/www.w3.org/2001/XMLSchema.dtd ``` after some time of quiet-ness, my code logs: ``` build 10-Jul-2025 07:38:19 07:38:19.698 [main] DEBUG myapp.lexicalstructure.DiyLSResourceResolver[resolve]:76 - Succesfully resolved systemId=http://www.w3.org/2001/XMLSchema.dtd publicId=-//W3C//DTD XMLSchema 200102//EN in 00:02:11.066. ```
dizzzz commented 2025-07-13 21:14:57 +02:00 (Migrated from github.com)

@ndw I will try the "access-external-entity" and "accessExternalDocument" , and set the protocols "file:,classpath,jar:" - does that make sense?

@ndw I will try the "access-external-entity" and "accessExternalDocument" , and set the protocols "file:,classpath,jar:" - does that make sense?
dizzzz commented 2025-07-14 09:06:40 +02:00 (Migrated from github.com)

that yields into

java.lang.IllegalArgumentException: lookupUri (access denied): http://www.w3.org/2000/09/xmldsig#
        at org.xmlresolver.XMLResolver.lookupUri(XMLResolver.java:387)
        at org.xmlresolver.XMLResolver.lookup(XMLResolver.java:253)
        at org.xmlresolver.XMLResolver.resolve(XMLResolver.java:443)
        at org.xmlresolver.adapters.LSResourceAdapter.resolveSchema(LSResourceAdapter.java:83)
        at org.xmlresolver.adapters.LSResourceAdapter.resolveResource(LSResourceAdapter.java:37)
        at MyApp.resolve(MyAppResolver.java:72)
        at MyAppResolver.resolveResource(MyAppResolver.java:108)
        at MyAppResolverTest.resolveXmlSigResource(MyAppResolverTest.java:48)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
that yields into ``` java.lang.IllegalArgumentException: lookupUri (access denied): http://www.w3.org/2000/09/xmldsig# at org.xmlresolver.XMLResolver.lookupUri(XMLResolver.java:387) at org.xmlresolver.XMLResolver.lookup(XMLResolver.java:253) at org.xmlresolver.XMLResolver.resolve(XMLResolver.java:443) at org.xmlresolver.adapters.LSResourceAdapter.resolveSchema(LSResourceAdapter.java:83) at org.xmlresolver.adapters.LSResourceAdapter.resolveResource(LSResourceAdapter.java:37) at MyApp.resolve(MyAppResolver.java:72) at MyAppResolver.resolveResource(MyAppResolver.java:108) at MyAppResolverTest.resolveXmlSigResource(MyAppResolverTest.java:48) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) at java.base/java.util.ArrayList.forEach(ArrayList.java:1596) ```
ndw commented 2025-07-14 18:25:57 +02:00 (Migrated from github.com)

I'm struggling to reproduce this.

        // Issue #253 suggests that this hits the web when it shouldn't.
        String dsig_ns = "http://www.w3.org/2000/09/xmldsig#";
        try {
            final InputSource inputSource = resolver.getEntityResolver().resolveEntity(dsig_ns, dsig_ns);
            Assertions.assertNotNull(inputSource);
        } catch (SAXException | IOException e) {
            fail(e.getMessage());
        }

That returns jar:file:/Volumes/Projects/xmlresolver/resolver/build/libs/xmlresolver-6.0.18-data.jar!/org/xmlresolver/www.w3.org/2000/09/xmldsig-core-schema.xsd

So it's not hitting the W3C. I have to say, that's a bad call to resolve entity; the first argument should be the system identifier of an XML entity and an XSD isn't an XML entity and that's not a system identfier. And passing that as the second argument is completely bogus because it definitely isn't a public identifier.

This also works for me:

        // Issue #253 suggests that this hits the web when it shouldn't.
        String dsig_ns = "http://www.w3.org/2000/09/xmldsig#";
        try {
            final LSInput lsInput = resolver.getLSResourceResolver().resolveResource(ResolverConstants.NATURE_XML_SCHEMA, dsig_ns, null, null, null);
            final InputSource inputSource = resolver.getEntityResolver().resolveEntity(dsig_ns, dsig_ns);
            Assertions.assertNotNull(inputSource);
        } catch (SAXException | IOException e) {
            fail(e.getMessage());
        }

It doesn't work if I leave the # off the end of the namespace URI, but I guess it shouldn't as that's not the namespace.

What is TestShared.XMLSIG_NS in your tests?

From elsewhere in your comment:

        // Issue #253 suggests that this hits the web when it shouldn't.
        try {
            final InputSource inputSource = resolver.getEntityResolver().resolveEntity(
                    "-//W3C//DTD XMLSchema 200102//EN",
                    "http://www.w3.org/2001/XMLSchema.dtd"
            );
            Assertions.assertNotNull(inputSource);
        } catch (SAXException | IOException e) {
            fail(e.getMessage());
        }

That succeeds for me as well, returning jar:file:/Volumes/Projects/xmlresolver/resolver/build/libs/xmlresolver-6.0.18-data.jar!/org/xmlresolver/www.w3.org/2001/XMLSchema.dtd.

Access denied is completely expected in your last comment. You said http access was forbidden and then tried to get an http: resource. That's a fail without even looking.

I'm struggling to reproduce this. ```java // Issue #253 suggests that this hits the web when it shouldn't. String dsig_ns = "http://www.w3.org/2000/09/xmldsig#"; try { final InputSource inputSource = resolver.getEntityResolver().resolveEntity(dsig_ns, dsig_ns); Assertions.assertNotNull(inputSource); } catch (SAXException | IOException e) { fail(e.getMessage()); } ``` That returns `jar:file:/Volumes/Projects/xmlresolver/resolver/build/libs/xmlresolver-6.0.18-data.jar!/org/xmlresolver/www.w3.org/2000/09/xmldsig-core-schema.xsd` So it's not hitting the W3C. I have to say, that's a bad call to resolve entity; the first argument should be the system identifier of an XML entity and an XSD isn't an XML entity and that's not a system identfier. And passing that as the second argument is completely bogus because it **definitely** isn't a public identifier. This also works for me: ```java // Issue #253 suggests that this hits the web when it shouldn't. String dsig_ns = "http://www.w3.org/2000/09/xmldsig#"; try { final LSInput lsInput = resolver.getLSResourceResolver().resolveResource(ResolverConstants.NATURE_XML_SCHEMA, dsig_ns, null, null, null); final InputSource inputSource = resolver.getEntityResolver().resolveEntity(dsig_ns, dsig_ns); Assertions.assertNotNull(inputSource); } catch (SAXException | IOException e) { fail(e.getMessage()); } ``` It doesn't work if I leave the `#` off the end of the namespace URI, but I guess it shouldn't as that's not the namespace. What is `TestShared.XMLSIG_NS` in your tests? From elsewhere in your comment: ```java // Issue #253 suggests that this hits the web when it shouldn't. try { final InputSource inputSource = resolver.getEntityResolver().resolveEntity( "-//W3C//DTD XMLSchema 200102//EN", "http://www.w3.org/2001/XMLSchema.dtd" ); Assertions.assertNotNull(inputSource); } catch (SAXException | IOException e) { fail(e.getMessage()); } ``` That succeeds for me as well, returning `jar:file:/Volumes/Projects/xmlresolver/resolver/build/libs/xmlresolver-6.0.18-data.jar!/org/xmlresolver/www.w3.org/2001/XMLSchema.dtd`. Access denied is completely expected in your last comment. You said `http` access was forbidden and then tried to get an `http:` resource. That's a fail without even looking.
ndw commented 2025-07-14 18:27:34 +02:00 (Migrated from github.com)

Can you make a small test program that reproduces the problem? What else is going on? Is this a multithreaded application sharing a resolver between threads? (I'm grasping at straws a bit.)

Your dump of the debug log shows that yes, the data jar is on the classpath, so I'm having a hard time imaging why it should succeed for me and fail for you...

Can you make a small test program that reproduces the problem? What else is going on? Is this a multithreaded application sharing a resolver between threads? (I'm grasping at straws a bit.) Your dump of the debug log shows that yes, the data jar *is* on the classpath, so I'm having a hard time imaging why it should succeed for me and fail for you...
dizzzz commented 2025-07-17 10:00:49 +02:00 (Migrated from github.com)

I (kinda) was able to isolate the issue; reminder: it only happens in an isolated build environment, with no internet access, but with access to a maven repository proxy.

The code:

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.w3c.dom.ls.LSInput;
import org.xmlresolver.ResolverConstants;
import org.xmlresolver.XMLResolver;

import java.io.IOException;
import java.io.InputStream;

import static org.junit.jupiter.api.Assertions.assertNotNull;

public class ResolverLSResourceTest {
    private XMLResolver resolver;

    @BeforeEach
    void beforeEach(final TestInfo testInfo) {
        System.out.println("Running test: " + testInfo.getDisplayName());
    }


    @BeforeEach
    public void setup() {
        resolver = new XMLResolver();
    }

    @Test
    public void xmldsig_xsd() throws IOException {
        final LSInput lsInput = resolver.getLSResourceResolver().resolveResource(ResolverConstants.NATURE_XML_SCHEMA, "http://www.w3.org/2000/09/xmldsig#", null, null, null);
        assertNotNull(lsInput);

        final InputStream byteStream = lsInput.getByteStream();
        assertNotNull(byteStream);

        // left out: Check content of stream
    }
}

this is the associated log:

build	16-Jul-2025 17:59:47  [INFO] Running ResolverLSResourceTest
error	16-Jul-2025 17:59:47  Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn
build     16-Jul-2025 17:59:47   Running test: xmldsig_xsd()
error     16-Jul-2025 17:59:47   WARNING: request: resolveResource: http://www.w3.org/2001/XMLSchema, null (namespace: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig), baseURI: null, publicId: null)
error     16-Jul-2025 17:59:47   Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn
error     16-Jul-2025 17:59:47   WARNING: request: lookupUri: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig) (baseURI: null)
error     16-Jul-2025 17:59:47   Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn
error     16-Jul-2025 17:59:47   WARNING: warning: Failed to GET: file:/usr/src/mymaven/diy-functions/diy-resolver/catalog.xml: /usr/src/mymaven/diy-functions/diy-resolver/catalog.xml (No such file or directory)
error     16-Jul-2025 17:59:47   response: getResource: false: file:/usr/src/mymaven/diy-functions/diy-resolver/catalog.xml
error     16-Jul-2025 17:59:47   Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn
error     16-Jul-2025 17:59:47   WARNING: error: Failed to load catalog: file:/usr/src/mymaven/diy-functions/diy-resolver/catalog.xml: /usr/src/mymaven/diy-functions/diy-resolver/catalog.xml (No such file or directory)
error     16-Jul-2025 17:59:47   Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn
error     16-Jul-2025 17:59:47   WARNING: error: Failed to load archived catalog: file:/usr/src/mymaven/diy-functions/diy-resolver/catalog.xml: /usr/src/mymaven/diy-functions/diy-resolver/catalog.xml (No such file or directory)
error     16-Jul-2025 17:59:47   response: getResource: true: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/catalog.xml
error     16-Jul-2025 17:59:47   Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn
error     16-Jul-2025 17:59:47   WARNING: response: lookupUri: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/www.w3.org/2000/09/xmldsig-core-schema.xsd

error     16-Jul-2025 18:01:58   Jul 16, 2025 4:01:58 PM org.xmlresolver.logging.SystemLogger warn
error     16-Jul-2025 18:01:58   WARNING: warning: Failed to GET: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig): Connection timed out
error     16-Jul-2025 18:01:58   response: getResource: false: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig)
error     16-Jul-2025 18:01:58   response: getResource: true: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig)
build     16-Jul-2025 18:01:58   [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 130.9 s -- in ResolverLSResourceTest

with the configuration

## xmlresolver.properties
## See https://xmlresolver.org/ch06

## 3. Specify protocol(s) allowed for URI access
#access-external-document=file:,jar:file:,classpath:

## 4. Specify protocol(s) allowed for entity access
#accessExternalEntity=file:,jar:file:,classpath:

## 7. Load catalogs from the classpath
classpath-catalogs=true

## 8. Preference for public or system identifiers
prefer=system

## 10. Always resolve resources
## If set to false, the resolver will return null if the resource isn?t found in the catalog.
always-resolve=false

## 14. The SAX parser factory class
#saxparserfactory-class=....

## 15. Use URI entries for system resolution
uri-for-system=true

## 16. Merge http: and https: URI schemes
merge-https=true

## 22. Throw URI exceptions?
#throw-uri-exceptions=false

## 25.1. The logger class
## org.xmlresolver.logging.DefaultLogger or org.xmlresolver.logging.SystemLogger (SLF4J)
resolver-logger-class=org.xmlresolver.logging.SystemLogger

## 25.2. The logging level
# default-logger-log-level
catalog-logging=response:warn,request:warn,warning:warn,error:warn

I (kinda) was able to isolate the issue; reminder: it only happens in an isolated build environment, with no internet access, but with access to a maven repository proxy. The code: ```java import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; import org.w3c.dom.ls.LSInput; import org.xmlresolver.ResolverConstants; import org.xmlresolver.XMLResolver; import java.io.IOException; import java.io.InputStream; import static org.junit.jupiter.api.Assertions.assertNotNull; public class ResolverLSResourceTest { private XMLResolver resolver; @BeforeEach void beforeEach(final TestInfo testInfo) { System.out.println("Running test: " + testInfo.getDisplayName()); } @BeforeEach public void setup() { resolver = new XMLResolver(); } @Test public void xmldsig_xsd() throws IOException { final LSInput lsInput = resolver.getLSResourceResolver().resolveResource(ResolverConstants.NATURE_XML_SCHEMA, "http://www.w3.org/2000/09/xmldsig#", null, null, null); assertNotNull(lsInput); final InputStream byteStream = lsInput.getByteStream(); assertNotNull(byteStream); // left out: Check content of stream } } ``` this is the associated log: ```log build 16-Jul-2025 17:59:47 [INFO] Running ResolverLSResourceTest error 16-Jul-2025 17:59:47 Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn build 16-Jul-2025 17:59:47 Running test: xmldsig_xsd() error 16-Jul-2025 17:59:47 WARNING: request: resolveResource: http://www.w3.org/2001/XMLSchema, null (namespace: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig), baseURI: null, publicId: null) error 16-Jul-2025 17:59:47 Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn error 16-Jul-2025 17:59:47 WARNING: request: lookupUri: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig) (baseURI: null) error 16-Jul-2025 17:59:47 Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn error 16-Jul-2025 17:59:47 WARNING: warning: Failed to GET: file:/usr/src/mymaven/diy-functions/diy-resolver/catalog.xml: /usr/src/mymaven/diy-functions/diy-resolver/catalog.xml (No such file or directory) error 16-Jul-2025 17:59:47 response: getResource: false: file:/usr/src/mymaven/diy-functions/diy-resolver/catalog.xml error 16-Jul-2025 17:59:47 Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn error 16-Jul-2025 17:59:47 WARNING: error: Failed to load catalog: file:/usr/src/mymaven/diy-functions/diy-resolver/catalog.xml: /usr/src/mymaven/diy-functions/diy-resolver/catalog.xml (No such file or directory) error 16-Jul-2025 17:59:47 Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn error 16-Jul-2025 17:59:47 WARNING: error: Failed to load archived catalog: file:/usr/src/mymaven/diy-functions/diy-resolver/catalog.xml: /usr/src/mymaven/diy-functions/diy-resolver/catalog.xml (No such file or directory) error 16-Jul-2025 17:59:47 response: getResource: true: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/catalog.xml error 16-Jul-2025 17:59:47 Jul 16, 2025 3:59:47 PM org.xmlresolver.logging.SystemLogger warn error 16-Jul-2025 17:59:47 WARNING: response: lookupUri: jar:file:/tmp/.m2/repository/org/xmlresolver/xmlresolver/6.0.18/xmlresolver-6.0.18-data.jar!/org/xmlresolver/www.w3.org/2000/09/xmldsig-core-schema.xsd error 16-Jul-2025 18:01:58 Jul 16, 2025 4:01:58 PM org.xmlresolver.logging.SystemLogger warn error 16-Jul-2025 18:01:58 WARNING: warning: Failed to GET: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig): Connection timed out error 16-Jul-2025 18:01:58 response: getResource: false: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig) error 16-Jul-2025 18:01:58 response: getResource: true: [http://www.w3.org/2000/09/xmldsig#](http://www.w3.org/2000/09/xmldsig) build 16-Jul-2025 18:01:58 [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 130.9 s -- in ResolverLSResourceTest ``` with the configuration ```properties ## xmlresolver.properties ## See https://xmlresolver.org/ch06 ## 3. Specify protocol(s) allowed for URI access #access-external-document=file:,jar:file:,classpath: ## 4. Specify protocol(s) allowed for entity access #accessExternalEntity=file:,jar:file:,classpath: ## 7. Load catalogs from the classpath classpath-catalogs=true ## 8. Preference for public or system identifiers prefer=system ## 10. Always resolve resources ## If set to false, the resolver will return null if the resource isn?t found in the catalog. always-resolve=false ## 14. The SAX parser factory class #saxparserfactory-class=.... ## 15. Use URI entries for system resolution uri-for-system=true ## 16. Merge http: and https: URI schemes merge-https=true ## 22. Throw URI exceptions? #throw-uri-exceptions=false ## 25.1. The logger class ## org.xmlresolver.logging.DefaultLogger or org.xmlresolver.logging.SystemLogger (SLF4J) resolver-logger-class=org.xmlresolver.logging.SystemLogger ## 25.2. The logging level # default-logger-log-level catalog-logging=response:warn,request:warn,warning:warn,error:warn ```
ndw commented 2025-07-17 10:20:46 +02:00 (Migrated from github.com)

Got it. It's an interesting interaction between RDDL support and "masking jar URIs". The resource is resolved, and RDDL wants to go take a peek in it, but masking jar URIs means that instead of returning the jar: URI that was resolved, it returns the original, and then we're off to www.w3.org for it.

Set parse-rddl=false in your configuration and I think the problem will go away. I'll fix that bug and probably make RDDL false by default.

Got it. It's an interesting interaction between RDDL support and "masking jar URIs". The resource is resolved, and RDDL wants to go take a peek in it, but masking jar URIs means that instead of returning the jar: URI that was resolved, it returns the original, and then we're off to www.w3.org for it. Set `parse-rddl=false` in your configuration and I think the problem will go away. I'll fix that bug and probably make RDDL false by default.
dizzzz commented 2025-07-17 10:52:16 +02:00 (Migrated from github.com)

On 1st glimpse, setting that property does not solve...

On 1st glimpse, setting that property does not solve...
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
XmlResolver/xmlresolver#253
No description provided.