Build can't resolve www.w3.org (NXDOMAIN)

Asked by John Neffenger

The build of the new Apache NetBeans 16 release candidate fails when it tries to resolve the host 'www.w3.org'. For details, see the latest failed build on the page below:

https://launchpad.net/~jgneff/+snap/strictly-netbeans

The actual error in the build log is:

java.net.UnknownHostException: www.w3.org

Yet I can recreate the error with a build script that runs only the 'curl' and 'host' commands. The 'curl' command works, making its connection through the proxy server:

+ curl -s http://www.w3.org/2001/xml.xsd
[19/Oct/2022:20:48:19 +0000] "GET http://www.w3.org/2001/xml.xsd HTTP/1.1" 200 8836 "-" "curl/7.58.0"
<?xml version='1.0'?>
<?xml-stylesheet href="../2008/09/xsd.xsl" type="text/xsl"?>
<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns ="http://www.w3.org/1999/xhtml"
  xml:lang="en">
  ...
</xs:schema>

But the 'host' command fails to resolve the host name directly:

+ host www.w3.org
Host www.w3.org not found: 3(NXDOMAIN)

Unfortunately, this direct name resolution is occurring deep within the 'javax.xml.parsers.DocumentBuilder' and 'java.net.Socket' classes of OpenJDK when trying to load an XML schema, so it's not easily bypassed in the application's build file.

Is there any way to resolve a host name behind the firewall on a Launchpad build machine?

Question information

Language:
English Edit question
Status:
Solved
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Solved by:
Colin Watson
Solved:
Last query:
Last reply:
Revision history for this message
Best Colin Watson (cjwatson) said :
#1

This isn't really possible, I'm afraid - DNS resolution is locked down in general as part of ensuring that Ubuntu builds are hermetic, and we don't have a good way to lift that restriction only for snap builds. Inserting an HTTP proxy as we do is logistically much easier to arrange.

Revision history for this message
John Neffenger (jgneff) said :
#2

Thanks Colin Watson, that solved my question.

Revision history for this message
John Neffenger (jgneff) said :
#3

I was able to fix this in the NetBeans build after all.

For details, see the bug report:

Build fails with UnknownHostException: www.w3.org
https://github.com/apache/netbeans/issues/4920

and the corresponding pull request:

Import local schema to avoid DNS lookup in build
https://github.com/apache/netbeans/pull/4933

John