rewrite icon indicating copy to clipboard operation
rewrite copied to clipboard

Failed to access maven repository http://maven.springframework.org/snapshot errors during rewrite:run

Open damogallagher opened this issue 1 year ago • 8 comments

Hi, as part of an evaluation, I am following the guide on Running OpenRewrite on a multi-module Maven project - https://docs.openrewrite.org/running-recipes/multi-module-maven I was just curious when using this approach, how do I resolve these warnings

[WARNING] Failed to access maven repository http://maven.springframework.org/snapshot due to: maven.springframework.org
[WARNING] Failed to access maven repository http://maven.springframework.org/milestone due to: maven.springframework.org
[WARNING] Failed to access maven repository http://maven.springframework.org/release due to: maven.springframework.org

This is the plugin config I am using

			<plugin>
				<groupId>org.openrewrite.maven</groupId>
				<artifactId>rewrite-maven-plugin</artifactId>
				<version>6.0.5</version>
				<configuration>
				<exportDatatables>true</exportDatatables>
				<activeRecipes>
					<recipe>org.openrewrite.staticanalysis.CodeCleanup</recipe>
					<!-- <recipe>org.openrewrite.java.migrate.UpgradeToJava21</recipe> -->
					<recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>
					<recipe>org.openrewrite.java.struts.migrate6.MigrateStruts6</recipe>
					<recipe>org.openrewrite.java.struts.migrate6.UpgradeStruts6Dependencies</recipe>
					<recipe>org.openrewrite.java.struts.migrate6.MigrateStruts6Constants</recipe>
					<recipe>org.openrewrite.java.struts.migrate6.MigrateAwareInterfaces</recipe>
					<recipe>org.openrewrite.java.struts.migrate6.MigrateOpenSymphonyClasses</recipe>
					<recipe>org.openrewrite.hibernate.MigrateToHibernate65</recipe>
				</activeRecipes>
				<activeStyles>
					<style>org.openrewrite.java.IntelliJ</style>
				</activeStyles>
				<failOnDryRunResults>true</failOnDryRunResults>
				<runPerSubmodule>true</runPerSubmodule>
				</configuration>
				<dependencies>
				<dependency>
					<groupId>org.openrewrite.recipe</groupId>
					<artifactId>rewrite-static-analysis</artifactId>
					<version>2.1.0</version>
				</dependency>
				<dependency>
					<groupId>org.openrewrite.recipe</groupId>
					<artifactId>rewrite-migrate-java</artifactId>
					<version>3.1.0</version>
				</dependency>
				<dependency>
					<groupId>org.openrewrite.recipe</groupId>
					<artifactId>rewrite-struts</artifactId>
					<version>0.11.0</version>
				</dependency>
				<dependency>
					<groupId>org.openrewrite.recipe</groupId>
					<artifactId>rewrite-hibernate</artifactId>
					<version>2.1.0</version>
				</dependency>				
				</dependencies>
			</plugin>

Also, when I run the mvn rewrite:run command with -X specified, here is the section for 1 of the stacktraces

[WARNING] Failed to access maven repository http://maven.springframework.org/snapshot due to: maven.springframework.org
[DEBUG] 
java.net.UnknownHostException: maven.springframework.org
    at sun.nio.ch.NioSocketImpl.connect (NioSocketImpl.java:567)
    at java.net.Socket.connect (Socket.java:760)
    at sun.net.NetworkClient.doConnect (NetworkClient.java:178)
    at sun.net.www.http.HttpClient.openServer (HttpClient.java:531)
    at sun.net.www.http.HttpClient.openServer (HttpClient.java:636)
    at sun.net.www.http.HttpClient.<init> (HttpClient.java:280)
    at sun.net.www.http.HttpClient.New (HttpClient.java:386)
    at sun.net.www.http.HttpClient.New (HttpClient.java:408)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient (HttpURLConnection.java:1310)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0 (HttpURLConnection.java:1243)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect (HttpURLConnection.java:1129)
    at sun.net.www.protocol.http.HttpURLConnection.connect (HttpURLConnection.java:1058)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0 (HttpURLConnection.java:1460)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream (HttpURLConnection.java:1423)
    at org.openrewrite.ipc.http.HttpUrlConnectionSender.send (HttpUrlConnectionSender.java:99)
    at org.openrewrite.maven.internal.MavenPomDownloader.lambda$sendRequest$1 (MavenPomDownloader.java:153)
    at dev.failsafe.Functions.lambda$toCtxSupplier$11 (Functions.java:243)
    at dev.failsafe.Functions.lambda$get$0 (Functions.java:46)
    at dev.failsafe.internal.RetryPolicyExecutor.lambda$apply$0 (RetryPolicyExecutor.java:74)
    at dev.failsafe.SyncExecutionImpl.executeSync (SyncExecutionImpl.java:187)
    at dev.failsafe.FailsafeExecutor.call (FailsafeExecutor.java:376)
    at dev.failsafe.FailsafeExecutor.get (FailsafeExecutor.java:112)
    at org.openrewrite.maven.internal.MavenPomDownloader.sendRequest (MavenPomDownloader.java:152)
    at org.openrewrite.maven.internal.MavenPomDownloader.reachable (MavenPomDownloader.java:886)
    at org.openrewrite.maven.internal.MavenPomDownloader.normalizeRepository (MavenPomDownloader.java:850)
    at org.openrewrite.maven.internal.MavenPomDownloader.normalizeRepository (MavenPomDownloader.java:805)
    at org.openrewrite.maven.internal.MavenPomDownloader.distinctNormalizedRepositories (MavenPomDownloader.java:741)
    at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:532)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPom (ResolvedPom.java:514)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentDependenciesRecursively (ResolvedPom.java:449)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively (ResolvedPom.java:397)
    at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:940)
    at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:855)
    at org.openrewrite.maven.tree.MavenResolutionResult.resolveDependencies (MavenResolutionResult.java:175)
    at org.openrewrite.maven.MavenParser.parseInputs (MavenParser.java:116)
    at org.openrewrite.Parser.parse (Parser.java:59)
    at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:553)
    at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:518)
    at org.openrewrite.maven.MavenMojoProjectParser.listSourceFiles (MavenMojoProjectParser.java:142)
    at org.openrewrite.maven.AbstractRewriteBaseRunMojo.loadSourceSet (AbstractRewriteBaseRunMojo.java:236)
    at org.openrewrite.maven.AbstractRewriteBaseRunMojo.listResults (AbstractRewriteBaseRunMojo.java:152)
    at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:64)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)

Any thoughts on how I can resolve this issue?

damogallagher avatar Jan 31 '25 01:01 damogallagher

I wonder where does maven.springframework.org even come from? When googling, I fail to see any mention. It doesn't seem mention in Rewrite codebase either.

greg-at-moderne avatar Jan 31 '25 09:01 greg-at-moderne

Yes I was wondering the same and also checked out the Rewrite codebase I am using a custom settings.xml file and I do not see any reference here. It is just pointing to my organizations repositories. No reference in the pom.xml in the maven module that is throwing the error either

damogallagher avatar Jan 31 '25 09:01 damogallagher

I suspect there could be some transitive parent or dependency declaring this repo. Quite possibly OpenRewrite should not try to consult this repo at all. It would be great if we could find out where this comes from and exactly what it is that OpenRewrite does and shouldn't do.

knutwannheden avatar Jan 31 '25 11:01 knutwannheden

I just found the location of these error messages

[WARNING] Failed to access maven repository http://maven.springframework.org/snapshot due to: maven.springframework.org
[WARNING] Failed to access maven repository http://maven.springframework.org/milestone due to: maven.springframework.org
[WARNING] Failed to access maven repository http://maven.springframework.org/release due to: maven.springframework.org

Please see this line in the rewrite-maven-plugin https://github.com/openrewrite/rewrite-maven-plugin/blob/main/src/main/java/org/openrewrite/maven/MavenLoggingResolutionEventListener.java#L48

I believe the error can be narrowed down to this chunk of code listed below

        Set<Path> allPoms = new LinkedHashSet<>();
        mavenProjects.forEach(p -> collectPoms(p, allPoms, mavenExecutionContext));
        for (MavenProject mavenProject : mavenProjects) {
            mavenSession.getProjectDependencyGraph().getUpstreamProjects(mavenProject, true).forEach(p -> collectPoms(p, allPoms, mavenExecutionContext));
        }

        MavenParser.Builder mavenParserBuilder = MavenParser.builder().mavenConfig(baseDir.resolve(MVN_MAVEN_CONFIG));
        List<String> activeProfiles = topLevelProject.getActiveProfiles().stream().map(Profile::getId).collect(toList());
        if (!activeProfiles.isEmpty()) {
            mavenParserBuilder.activeProfiles(activeProfiles.toArray(new String[0]));
        }

        List<SourceFile> mavens = mavenParserBuilder.build()
                .parse(allPoms, baseDir, ctx)
                .collect(toList());

damogallagher avatar Jan 31 '25 11:01 damogallagher

I think the questions are:

  • where is this repo declared
  • is correct for OpenRewrite to query it?
  • if not, why not?

knutwannheden avatar Jan 31 '25 12:01 knutwannheden

The repo is located privately within my organization and it The pom file contains a few internal libraries, old version of spring, hibernete, junit - all fairly standard

damogallagher avatar Jan 31 '25 12:01 damogallagher

@greg-at-moderne / @knutwannheden any thoughts on how we can proceed here?

damogallagher avatar Feb 04 '25 14:02 damogallagher

I also have run into this while trying to upgrade a quakus application using the quarkus-cli. In my case, we're using a GCP Artifact Registry, and have the transport for it that's found in the com.google.cloud.artifactregistry:artifactregistry-maven-wagon maven plugin.

I see a lot of errors that like this when attempting the upgrade:

Failed to access maven repository artifactregistry://us-maven.pkg.dev/gcp-project-id/gcp-repo-name-with-maven-central-passthrough due to: Repository artifactregistry://us-maven.pkg.dev/gcp-project-id/gcp-repo-name-with-maven-central-passthrough is not HTTP(S).

madiath-bilt avatar Jun 02 '25 20:06 madiath-bilt