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

Do not throw "InvalidPathException: Illegal char" when encountering bill of materials POM in <dependencies> section #3167

Closed
magicwerk opened this issue Jan 17, 2023 · 15 comments · Fixed by #3169
Assignees
Labels
bug Something isn't working

Comments

@magicwerk
Copy link

magicwerk commented Jan 17, 2023

Refactoring fails with exception in MavenPomDownloader.download.
This errors can be triggered by adding the following dependency

	<dependency>
		<groupId>org.wildfly</groupId>
		<artifactId>wildfly-jms-client-bom</artifactId>
		<version>24.0.1.Final</version>
		<type>pom</type>
		<scope>test</scope>
	</dependency>

and the openrewrite plugin to a freshly created Maven project (see attached example project)

mvn rewrite:run -Drewrite.activeRecipes=ChangePackageExample -X

[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run (default-cli) on project my-app: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run failed: Illegal char <:> at index 10: org.apache:apache\pom.xml -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run (default-cli) on project my-app: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run failed: Illegal char <:> at index 10: org.apache:apache\pom.xml
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run failed: Illegal char <:> at index 10: org.apache:apache\pom.xml
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 10: org.apache:apache\pom.xml
    at sun.nio.fs.WindowsPathParser.normalize (WindowsPathParser.java:182)
    at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:153)
    at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:77)
    at sun.nio.fs.WindowsPath.parse (WindowsPath.java:92)
    at sun.nio.fs.WindowsFileSystem.getPath (WindowsFileSystem.java:229)
    at java.nio.file.Path.of (Path.java:147)
    at java.nio.file.Paths.get (Paths.java:69)
    at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:459)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:353)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:364)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:364)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively (ResolvedPom.java:310)
    at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:586)
    at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:502)
    at org.openrewrite.maven.tree.MavenResolutionResult.resolveDependencies (MavenResolutionResult.java:179)
    at org.openrewrite.maven.MavenParser.parseInputs (MavenParser.java:124)
    at org.openrewrite.Parser.parse (Parser.java:41)
    at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:309)
    at org.openrewrite.maven.MavenMojoProjectParser.listSourceFiles (MavenMojoProjectParser.java:119)
    at org.openrewrite.maven.AbstractRewriteMojo.listResults (AbstractRewriteMojo.java:221)
    at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:48)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

Test case:
unzip my-app.zip
execute mvn rewrite:run -Drewrite.activeRecipes=ChangePackageExample -X

my-app.zip

@timtebeek timtebeek added bug Something isn't working question Further information is requested and removed bug Something isn't working labels Jan 17, 2023
@timtebeek
Copy link
Contributor

Hi @magicwerk thanks for the detailed report! I've opened it up just now and it appears there's something odd about the way you use the wildfly bill of materials, and I see the same issue with Maven without OpenRewrite.

You've declared a test scoped dependency on the bill of materials, but there's no jar associated with that pom.xml:
https://repo1.maven.org/maven2/org/wildfly/wildfly-jms-client-bom/24.0.1.Final/ only shows

org/wildfly/wildfly-jms-client-bom/24.0.1.Final
../
wildfly-jms-client-bom-24.0.1.Final.pom           2021-07-27 16:48     14528
wildfly-jms-client-bom-24.0.1.Final.pom.md5       2021-07-27 16:48        32
wildfly-jms-client-bom-24.0.1.Final.pom.sha1      2021-07-27 16:48        40

Could it be that you instead had wanted to use <scope>import</scope>, as is customary with BOM files?

	<dependency>
		<groupId>org.wildfly</groupId>
		<artifactId>wildfly-jms-client-bom</artifactId>
		<version>24.0.1.Final</version>
		<type>pom</type>
		<scope>import</scope>
	</dependency>

Such an entry can then go into your <dependencyManagement> section to influence artifact version resolution, as described here.

If I've misunderstood please let me know!

@magicwerk
Copy link
Author

Hi, thanks for the prompt answer.

Can you explain what you mean with seeing the same issue with without OpenRewrite?
On the example project, I can run mvn install without problems, but mvn rewrite:run fails as shown.

On the other hand it could as well be that the mentioned dependency is incorrect, but is is part as indicated in our project - where mvn install works, but mvn rewrite:run fails as in the example - let me check that.

Nevertheless I think it is also strange if a meaningless or incorrect dependency cause openrewrite to fail with an error, if Maven is somehow able to handle it - maybe the error could be caught and and warning issued?

@timtebeek
Copy link
Contributor

My IDE initially failed to resolve wildfly-jms-client-bom as well; but after running Maven on the command line you're right that Maven does allow that unexpected use of a BOM file.

You're right in that we should not throw an exception if Maven does not throw an exception under the same circumstances. We can keep this issue open to track that.

Are you able to continue without that BOM in your dependencies section? Maybe even move it to dependency management & change the scope to import? Would not want this to block you from applying recipes, but don't know if we'll get to handling this edge case soon enough.

@timtebeek timtebeek changed the title mvn rewrite:run fails with InvalidPathException: Illegal char Do not throw "InvalidPathException: Illegal char" when encountering bill of materials POM in <dependencies> section Jan 17, 2023
@timtebeek timtebeek added enhancement New feature or request and removed question Further information is requested labels Jan 17, 2023
@magicwerk
Copy link
Author

I made some further attempts to made openrewrite work with our projects, but failed again.
Here's another dependency which causes the same failure, which is not a BOM this case, but a simple JAR:

	<dependency>
		<groupId>org.apache.activemq</groupId>
		<artifactId>artemis-jms-client</artifactId>
		<version>2.16.0</version>
	</dependency>

So IMHO this seems not be an edge case and I would consider it rather being a bug than an enhancement.

@timtebeek
Copy link
Contributor

@magicwerk tried it just now and I'm getting a different error message with artemis-jms-client

[ERROR]         <!--~~(io.netty:netty-transport-native-epoll failed. No version provided)~~>--><!--~~(io.netty:netty-transport-native-kqueue failed. No version provided)~~>--><dependency>
[ERROR]             <groupId>org.apache.activemq</groupId>
[ERROR]             <artifactId>artemis-jms-client</artifactId>
[ERROR]             <version>2.16.0</version>
[ERROR]         </dependency>

Can you confirm you're getting that different error message as well, as opposed to the InvalidPathException earlier?
That would make it a different issue, which we can track separately from this one.

@magicwerk
Copy link
Author

It's exactly the same on my machine:

mvn rewrite:run -Drewrite.activeRecipes=ChangePackageExample
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> rewrite-maven-plugin:4.38.2:run (default-cli) > compile @ my-app >>>
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ my-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\dev\Temp\OpenRewrite\my-app\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< rewrite-maven-plugin:4.38.2:run (default-cli) < compile @ my-app <<<
[INFO]
[INFO]
[INFO] --- rewrite-maven-plugin:4.38.2:run (default-cli) @ my-app ---
[INFO] Using active recipe(s) [ChangePackageExample]
[INFO] Using active styles(s) []
[INFO] Validating active recipes...
[INFO] Project [my-app] Resolving Poms...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.063 s (Wall Clock)
[INFO] Finished at: 2023-01-18T16:29:33+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run (default-cli) on project my-app: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run failed: Illegal char <:> at index 10: org.apache:apache\pom.xml -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run (default-cli) on project my-app: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run failed: Illegal char <:> at index 10: org.apache:apache\pom.xml -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run (default-cli) on project my-app: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run failed: Illegal char <:> at index 10: org.apache:apache\pom.xml
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run failed: Illegal char <:> at index 10: org.apache:apache\pom.xml
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 10: org.apache:apache\pom.xml
at sun.nio.fs.WindowsPathParser.normalize (WindowsPathParser.java:182)
at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:153)
at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:77)
at sun.nio.fs.WindowsPath.parse (WindowsPath.java:92)
at sun.nio.fs.WindowsFileSystem.getPath (WindowsFileSystem.java:229)
at java.nio.file.Path.of (Path.java:147)
at java.nio.file.Paths.get (Paths.java:69)
at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:459)
at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:353)
at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:364)
at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively (ResolvedPom.java:310)
at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:586)
at org.openrewrite.maven.tree.ResolvedPom.resolveDependencies (ResolvedPom.java:502)
at org.openrewrite.maven.tree.MavenResolutionResult.resolveDependencies (MavenResolutionResult.java:179)
at org.openrewrite.maven.MavenParser.parseInputs (MavenParser.java:124)
at org.openrewrite.Parser.parse (Parser.java:41)
at org.openrewrite.maven.MavenMojoProjectParser.parseMaven (MavenMojoProjectParser.java:309)
at org.openrewrite.maven.MavenMojoProjectParser.listSourceFiles (MavenMojoProjectParser.java:119)
at org.openrewrite.maven.AbstractRewriteMojo.listResults (AbstractRewriteMojo.java:221)
at org.openrewrite.maven.AbstractRewriteRunMojo.execute (AbstractRewriteRunMojo.java:48)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

@timtebeek
Copy link
Contributor

Weird how that's the same issue indeed; and that BOM is not coming in through a parent for instance?

I'll log a separate issue with the dependency resolution that I saw locally for artemis-jms-client.

@magicwerk
Copy link
Author

I'm not sure what you mean with BOM, I can reproduce the behavior with the same tiny maven project i sent you yesterday, just by replacing the dependency.
That's I was saying it does not seem only to be an edge case and i would rather consider it a bug.

4.0.0
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>

<name>my-app</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<maven.compiler.source>1.7</maven.compiler.source>
	<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<dependencies>
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.11</version>
		<scope>test</scope>
	</dependency>
	
	<dependency>
		<groupId>org.apache.activemq</groupId>
		<artifactId>artemis-jms-client</artifactId>
		<version>2.16.0</version>
	</dependency>

</dependencies>

<build>
	<pluginManagement>
		<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
		<plugins>
			<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
				<version>3.1.0</version>
			</plugin>
			<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<version>3.0.2</version>
			</plugin>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.0</version>
			</plugin>
			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.22.1</version>
			</plugin>
			<plugin>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.0.2</version>
			</plugin>
			<plugin>
				<artifactId>maven-install-plugin</artifactId>
				<version>2.5.2</version>
			</plugin>
			<plugin>
				<artifactId>maven-deploy-plugin</artifactId>
				<version>2.8.2</version>
			</plugin>
			<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
			<plugin>
				<artifactId>maven-site-plugin</artifactId>
				<version>3.7.1</version>
			</plugin>
			<plugin>
				<artifactId>maven-project-info-reports-plugin</artifactId>
				<version>3.0.0</version>
			</plugin>
		</plugins>
	</pluginManagement>

	<plugins>
		<plugin>
			<groupId>org.openrewrite.maven</groupId>
			<artifactId>rewrite-maven-plugin</artifactId>
			<version>4.38.2</version>
			<configuration>
				<exclusions>
					<exclude>**/*.json</exclude>
					<exclude>**/*.xml</exclude>
					<exclude>**/*.zip</exclude>
				</exclusions>
			</configuration>
		</plugin>

	</plugins>
</build>

@timtebeek
Copy link
Contributor

Yes I've logged openrewrite/rewrite-maven-plugin#478 separately, as to me those two issues seem unrelated, if quite unfortunate that you're affected twice! More details about that last one in the other issue, but feel free to add any more details that you feel could help debugging there.

@magicwerk
Copy link
Author

I'm quite astonished... As said, If I unpack my-app-new.zip and execute
mvn rewrite:run -Drewrite.activeRecipes=ChangePackageExample

I get

[INFO] --- rewrite-maven-plugin:4.38.2:run (default-cli) @ my-app ---
[INFO] Using active recipe(s) [ChangePackageExample]
[INFO] Using active styles(s) []
[INFO] Validating active recipes...
[INFO] Project [my-app] Resolving Poms...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.002 s
[INFO] Finished at: 2023-01-18T16:58:32+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run (default-cli) on project my-app: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.38.2:run failed: Illegal char <:> at index 10: org.apache:apache\pom.xml -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

That's different at your site?

my-app-new.zip

@timtebeek
Copy link
Contributor

Yes; when I run your sample I see the io.netty:netty-transport-native-epoll failed. No version provided error logged in openrewrite/rewrite-maven-plugin#478 . on Ubuntu with

openjdk version "1.8.0_352"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_352-b08)
OpenJDK 64-Bit Server VM (Temurin)(build 25.352-b08, mixed mode)

Hence why I logged that as a separate issue; not sure why you're seeing different results.

@magicwerk
Copy link
Author

My example run on Windows 10

java -version
java version "11.0.13" 2021-10-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.13+10-LTS-370)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.13+10-LTS-370, mixed mode)

@rrvk
Copy link

rrvk commented Jan 31, 2023

I have the same issue
You can add this to your config(in your pom) so it will still run and ignore that error
<skipMavenParsing>true</skipMavenParsing>

@hawkeye-bot
Copy link

hawkeye-bot commented Apr 26, 2023

I ran into this as well, and I think I understand what's going wrong (at least roughly). If you run the maven plugin with -X (debug) enabled, you get the following stacktrace (only copied the relevant part):

Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 10: org.apache:apache\pom.xml
    at sun.nio.fs.WindowsPathParser.normalize (WindowsPathParser.java:182)
    at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:153)
    at sun.nio.fs.WindowsPathParser.parse (WindowsPathParser.java:77)
    at sun.nio.fs.WindowsPath.parse (WindowsPath.java:92)
    at sun.nio.fs.WindowsFileSystem.getPath (WindowsFileSystem.java:232)
    at java.nio.file.Path.of (Path.java:147)
    at java.nio.file.Paths.get (Paths.java:69)
    at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:454)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPom (ResolvedPom.java:413)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:353)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentPropertiesAndRepositoriesRecursively (ResolvedPom.java:363)
    at org.openrewrite.maven.tree.ResolvedPom$Resolver.resolveParentsRecursively (ResolvedPom.java:310)

This in fact is a pretty good indication the last part of openrewrite it comes from is at org.openrewrite.maven.internal.MavenPomDownloader.download (MavenPomDownloader.java:454)
(using version 4.43.0 here). It indicates it's trying to download the parent pom from the dependency, but this actually fails because this is set in the parent-pom (artemis-pom) of the artemis dependency:

   <parent>
      <groupId>org.apache</groupId>
      <artifactId>apache</artifactId>
      <version>27</version>
      <relativePath>org.apache:apache</relativePath>
   </parent>

See https://central.sonatype.com/artifact/org.apache.activemq/artemis-pom/2.28.0

It parses this parent pom, and finds the relative path, and you can clearly see the : in the relativepath at character index 10 where it's failing. It then simply tries to find this as a plain file on the filesystem, which obviously doesn't exist. Whether or not it is correct to use the relativePath I can't decide, but this is where the problem is coming from I believe. In these cases, it shouldn't try to look up the file on the filesystem, but instead treat it as a 'normal' resolveable dependency I think?

@timtebeek timtebeek self-assigned this Apr 26, 2023
@timtebeek timtebeek added bug Something isn't working and removed enhancement New feature or request labels Apr 26, 2023
@timtebeek
Copy link
Contributor

Thanks for chiming in here with your analysis @hawkeye-bot ! Especially love the small details such as (using version 4.43.0 here) that make this that much easier to follow up on. Now I have a clear view on what's causing the issue and we can look at resolving it finally.

@timtebeek timtebeek transferred this issue from openrewrite/rewrite-maven-plugin Apr 26, 2023
timtebeek added a commit that referenced this issue Apr 26, 2023
Fixes #3167

artemis-pom-2.28.0.pom contains a weird relative path:
https://repo1.maven.org/maven2/org/apache/activemq/artemis-pom/2.28.0/artemis-pom-2.28.0.pom

```xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.activemq</groupId>
    <artifactId>artemis-pom</artifactId>
    <packaging>pom</packaging>
    <version>2.28.0</version>
    <parent>
        <groupId>org.apache</groupId>
        <artifactId>apache</artifactId>
        <version>27</version>
        <relativePath>org.apache:apache</relativePath>
    </parent>
```

This worked okay-ish on Linux/Mac, as passing the relativePath into `Paths.get(relativePath, "pom.xml")` will just result in a null `maybeLocalPom`. On Windows however, a colon is not valid to pass into Paths.get(..), and it fails with the reported exception.

Since we were effectively ignoring the relative path on Mac/Linux before, we might as well skip it entirely for Windows as well.
timtebeek added a commit that referenced this issue Apr 26, 2023
Fixes #3167

artemis-pom-2.28.0.pom contains a weird relative path:
https://repo1.maven.org/maven2/org/apache/activemq/artemis-pom/2.28.0/artemis-pom-2.28.0.pom

```xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.activemq</groupId>
    <artifactId>artemis-pom</artifactId>
    <packaging>pom</packaging>
    <version>2.28.0</version>
    <parent>
        <groupId>org.apache</groupId>
        <artifactId>apache</artifactId>
        <version>27</version>
        <relativePath>org.apache:apache</relativePath>
    </parent>
```

This worked okay-ish on Linux/Mac, as passing the relativePath into `Paths.get(relativePath, "pom.xml")` will just result in a null `maybeLocalPom`. On Windows however, a colon is not valid to pass into Paths.get(..), and it fails with the reported exception.

Since we were effectively ignoring the relative path on Mac/Linux before, we might as well skip it entirely for Windows as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants