Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
damogallagher opened this issue Jan 31, 2025 · 7 comments

Comments

@damogallagher
Copy link

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?

@greg-at-moderne
Copy link
Contributor

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.

@damogallagher
Copy link
Author

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

@knutwannheden
Copy link
Contributor

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.

@damogallagher
Copy link
Author

damogallagher commented Jan 31, 2025

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());

@knutwannheden
Copy link
Contributor

I think the questions are:

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

@damogallagher
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants