Uploaded image for project: 'JBoss Modules'
  1. JBoss Modules
  2. MODULES-410

MavenArtifactUtil can't work with file:// protocol in repository url

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • None
    • 1.11.0.Final, 2.0.0.Final
    • Maven
    • None

      Even when repositories defined in settings.xml are often thought of as remote ones, the <url> attribute works with file:// url as well (which can be handy for various reasons but more importantly it is a valid configuration we should work with, see https://maven.apache.org/guides/introduction/introduction-to-repositories.html).

      Unfortunatelly, it seems MavenArtifactUtil class only works with http:// and https:// urls as it always tries to cast opened connection to the HttpURLConnection.

      This ends up with eg:

      2021-11-03 11:17:17,834 WARN  [org.jboss.modules.define] (main) Failed to define class org.wildfly.security.WildFlyElytronProvider in Module "org.wildfly.security.elytron-base" version 1.17.1.Final from local module loader @4566d049 (finder: local module finder @61ce23ac (roots: /tmp/resteasy/testsuite/integration-tests/target/wildfly/modules,/tmp/resteasy/testsuite/integration-tests/target/wildfly/modules/system/layers/base)): java.lang.ClassCastException: class sun.net.www.protocol.file.FileURLConnection cannot be cast to class java.net.HttpURLConnection (sun.net.www.protocol.file.FileURLConnection and java.net.HttpURLConnection are in module java.base of loader 'bootstrap')
      	at org.jboss.modules.maven.MavenArtifactUtil.downloadFile(MavenArtifactUtil.java:161)
      	at org.jboss.modules.maven.MavenArtifactUtil.resolveArtifact(MavenArtifactUtil.java:135)
      	at org.jboss.modules.maven.DefaultMavenResolver.lambda$resolveArtifact$0(DefaultMavenResolver.java:36)
      	at java.base/java.security.AccessController.doPrivileged(Native Method)
      	at org.jboss.modules.maven.MavenArtifactUtil.doIo(MavenArtifactUtil.java:237)
      	at org.jboss.modules.maven.DefaultMavenResolver.resolveArtifact(DefaultMavenResolver.java:36)
      	at org.jboss.modules.maven.MavenResolver.resolveJarArtifact(MavenResolver.java:40)
      	at org.jboss.modules.xml.ModuleXmlParser.parseArtifact(ModuleXmlParser.java:1049)
      	at org.jboss.modules.xml.ModuleXmlParser.parseResources(ModuleXmlParser.java:938)
      	at org.jboss.modules.xml.ModuleXmlParser.parseModuleContents(ModuleXmlParser.java:698)
      	at org.jboss.modules.xml.ModuleXmlParser.parseDocument(ModuleXmlParser.java:469)
      	at org.jboss.modules.xml.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:335)
      	at org.jboss.modules.xml.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:293)
      	at org.jboss.modules.xml.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:254)
      	at org.jboss.modules.LocalModuleFinder.parseModuleXmlFile(LocalModuleFinder.java:250)
      	at org.jboss.modules.LocalModuleFinder.lambda$findModule$1(LocalModuleFinder.java:195)
      	at java.base/java.security.AccessController.doPrivileged(Native Method)
      	at org.jboss.modules.LocalModuleFinder.findModule(LocalModuleFinder.java:195)
      	at org.jboss.modules.ModuleLoader.findModule0(ModuleLoader.java:700)
      	at org.jboss.modules.ModuleLoader.findModule(ModuleLoader.java:693)
      	at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:503)
      	at org.jboss.modules.DelegatingModuleLoader.preloadModule(DelegatingModuleLoader.java:57)
      	at org.jboss.modules.Module.addExportedPaths(Module.java:1425)
      	at org.jboss.modules.Module.addPaths(Module.java:1317)
      	at org.jboss.modules.Module.link(Module.java:1644)
      	at org.jboss.modules.Module.getPaths(Module.java:1605)
      	at org.jboss.modules.Module.getPathsUnchecked(Module.java:1628)
      	at org.jboss.modules.Module.loadModuleClass(Module.java:748)
      	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
      	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
      	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
      	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
      	at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:423)
      	at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:555)
      	at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339)
      	at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126)
      	at org.jboss.modules.Module.loadModuleClass(Module.java:753)
      	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
      	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
      	at java.base/java.lang.Class.forName0(Native Method)
      	at java.base/java.lang.Class.forName(Class.java:398)
      	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1210)
      	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1221)
      	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1265)
      	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1300)
      	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1385)
      	at org.jboss.modules.Main.main(Main.java:596)
      

              Unassigned Unassigned
              jbliznak@redhat.com Jan Blizňák
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: