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

NPE in daemon prompter when using iteractive mode with no project (using archetype) #807

Closed
rmannibucau opened this issue Mar 10, 2023 · 4 comments
Assignees
Milestone

Comments

@rmannibucau
Copy link
Contributor

Here is the stack

$ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] BuildTimeEventSpy is registered.
[INFO] 
[INFO] -------------------------------------------< org.apache.maven:standalone-pom >--------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ---------------------------------------------------------[ pom ]----------------------------------------------------------
[INFO] 
[INFO] --- archetype:3.2.0:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [org.apache.maven.archetypes:maven-archetype-quickstart:1.4] found in catalog remote
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] --------------------------------------------------------------------------------------------------------------------------
[INFO] Total time:  1.860 s
[INFO] Finished at: 2023-03-10T10:00:51+01:00
[INFO] --------------------------------------------------------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.0:generate (default-cli) on project standalone-pom: Failed to prompt user: Unable to prompt user: NullPointerException -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.0:generate (default-cli) on project standalone-pom: Failed to prompt user
	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:341)
	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:324)
	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:77)
	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:114)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:60)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:132)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:313)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:228)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:859)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:282)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:198)
...
Caused by: java.io.IOException: Unable to prompt user
	at org.mvndaemon.mvnd.interactivity.DaemonPrompter.doPrompt(DaemonPrompter.java:175)
	at org.mvndaemon.mvnd.interactivity.DaemonPrompter.doPrompt(DaemonPrompter.java:111)
	... 32 common frames omitted
Caused by: java.lang.NullPointerException: null
	at java.base/java.util.Objects.requireNonNull(Objects.java:221)
	at org.mvndaemon.mvnd.interactivity.DaemonPrompter.doPrompt(DaemonPrompter.java:166)
	... 33 common frames omitted
@psiroky
Copy link
Contributor

psiroky commented Mar 10, 2023

Which version of mvnd are you seeing this with? I tried with 0.9.0 and the latest master (ca4bdd0), but could not reproduce.

That being said, DaemonPrompter.java:166 contains Connection con = Objects.requireNonNull(Connection.getCurrent()); which seems like the the connection got lost for some reason? But then I am not sure how would the error message / stacktrace got to the client.

@gnodet
Copy link
Contributor

gnodet commented Mar 10, 2023

Which version of mvnd are you seeing this with? I tried with 0.9.0 and the latest master (ca4bdd0), but could not reproduce.

That being said, DaemonPrompter.java:166 contains Connection con = Objects.requireNonNull(Connection.getCurrent()); which seems like the the connection got lost for some reason? But then I am not sure how would the error message / stacktrace got to the client.

I think that's using the mvn script from mvnd, that's why there's no connection...
But the DaemonPrompter is used anyway, so I think, if there's no connection, it should delegate to the usual one (or duplicate the behaviour and go to the console). An alternative would be to split the classpath so that when launching maven, the class loader would not contain any maven daemon specific classes.
It should be easier, now that all processes are using the plexus class world's launcher to boot.

@rmannibucau
Copy link
Contributor Author

Think the option to have a mvn.m2.conf and a mvnd.m2.conf is very tempting.

@gnodet
Copy link
Contributor

gnodet commented Mar 10, 2023

Think the option to have a mvn.m2.conf and a mvnd.m2.conf is very tempting.

We already have 3 configs in the master: one for maven, one for the mvnd client and one for the mvnd daemon. So it's just a matter of modifying the distribution / config so that the daemon jars are not included when starting maven.

@gnodet gnodet self-assigned this Mar 13, 2023
gnodet added a commit to gnodet/mvnd that referenced this issue Mar 13, 2023
…fixes apache#807

* the logging framework is extracted into its own jar and moved in the mvn/lib/ directory
* the other daemon jars are moved into the mvn/lib/mvnd directory and not used by maven at all
This makes maven class loader almost identical to the stock maven classloader, but for the logging framework
@gnodet gnodet added this to the 1.0.0-m5 milestone Mar 13, 2023
@gnodet gnodet closed this as completed in 0e057cb Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants