Skip to content

Calling mavenCli from org.apache.maven:maven-embedder causes a crash #44573

Open
@mooujarrar

Description

Describe the bug

I am trying to use the dependency:

<dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-embedder</artifactId> <version>3.9.9</version> </dependency>

To call maven programmatically, but that seems to fail.

Expected behavior

No response

Actual behavior

The server fails in the invocation part of maven cli:

int result = mavenCli.doMain(
new String[]{"org.jvnet.jaxb:jaxb-maven-plugin:generate", "-X", "-e"},
basePath.toString(),
System.out, System.err
);

But launching this goal directly from maven (mvnw org.jvnet.jaxb:jaxb-maven-plugin:generate) from the command line (outside quarkus) seems to work fine

The call stack:

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: C:\Users\user.m2\wrapper\dists\apache-maven-3.9.9-bin\33b4b2b4\apache-maven-3.9.9
Java version: 17.0.8.1, vendor: Azul Systems, Inc., runtime: C:\Java\zulu17
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

2024-11-19 13:23:40,828 INFO [org.apa.mav.cli.MavenCli] (executor-thread-1) Error stacktraces are turned on.
2024-11-19 13:23:40,864 ERROR [org.apa.mav.cli.MavenCli] (executor-thread-1) Internal error: java.lang.NullPointerException: Cannot invoke "org.eclipse.aether.impl.LocalRepositoryProvider.newLocalRepositoryManager(org.eclipse.aether.RepositorySystemSession, org.eclipse.aether.repository.LocalRepository)" because "this.localRepositoryProvider" is null -> [Help 1]: org.apache.maven.InternalErrorException: Internal error:
java.lang.NullPointerException: Cannot invoke "org.eclipse.aether.impl.LocalRepositoryProvider.newLocalRepositoryManager(org.eclipse.aether.RepositorySystemSession, org.eclipse.aether.repository.LocalRepository)" because "this.localRepositoryProvider" is null
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:109)
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.doMain(MavenCli.java:248)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:627)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.aether.impl.LocalRepositoryProvider.newLocalRepositoryManager(org.eclipse.aether.RepositorySystemSession, org.eclipse.aether.repository.LocalRepository)" because "this.localRepositoryProvider" is null
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.newLocalRepositoryManager(DefaultRepositorySystem.java:403)
at org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory.setUpLocalRepositoryManager(DefaultRepositorySystemSessionFactory.java:369)
at org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory.newRepositorySession(DefaultRepositorySystemSessionFactory.java:360)
at org.apache.maven.DefaultMaven.newRepositorySession(DefaultMaven.java:312)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:166)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:101)
... 18 more

2024-11-19 13:23:40,873 ERROR [org.apa.mav.cli.MavenCli] (executor-thread-1)
2024-11-19 13:23:40,875 ERROR [org.apa.mav.cli.MavenCli] (executor-thread-1) Re-run Maven using the -X switch to enable full debug logging.
2024-11-19 13:23:40,876 ERROR [org.apa.mav.cli.MavenCli] (executor-thread-1)
2024-11-19 13:23:40,876 ERROR [org.apa.mav.cli.MavenCli] (executor-thread-1) For more information about the errors and possible solutions, please read the following articles:
2024-11-19 13:23:40,877 ERROR [org.apa.mav.cli.MavenCli] (executor-thread-1) [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException
2024-11-19 13:23:40,879 WARN [Sisu] (executor-thread-1) Problem stopping: public void org.apache.maven.internal.aether.ResolverLifecycle.shutdown(): java.lang.NullPointerException: Cannot invoke "org.eclipse.aether.impl.RepositorySystemLifecycle.systemEnded()" because "this.repositorySystemLifecycle" is null
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.shutdown(DefaultRepositorySystem.java:446)
at org.apache.maven.internal.aether.ResolverLifecycle.shutdown(ResolverLifecycle.java:48)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.eclipse.sisu.bean.BeanLifecycle.stop(BeanLifecycle.java:133)
at org.eclipse.sisu.bean.LifecycleManager.unmanage(LifecycleManager.java:85)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.unmanage(PlexusLifecycleManager.java:177)
at org.codehaus.plexus.DefaultPlexusContainer.dispose(DefaultPlexusContainer.java:592)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:299)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:248)
at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:627)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)

How to Reproduce?

No response

Output of uname -a or ver

Microsoft Windows [Version 10.0.19045.5011]

Output of java -version

Java version: 17.0.8.1

Quarkus version or git rev

3.16.3

Build tool (ie. output of mvnw --version or gradlew --version)

3.9.9

Additional information

No response

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions