Skip to content

Maven install fails with NPE #745

@hohwille

Description

@hohwille

Expected behavior

As a IDEasy user, I want to get helpful error messages in case of config errors and a robust behaviour so that I do not waste my time with deep debugging of the product internals.

Actual behavior

$ ide install mvn
Start: Install mvn
Step 'ide (install,mvn)' failed: java.lang.NullPointerException
 Step 'Install mvn (null)' failed: java.lang.NullPointerException
2 step(s) failed out of 3 steps.
An unexpected error occurred!
We are sorry for the inconvenience.
Please check the error below, resolve it and try again.
If the error is not on your end (network connectivity, lack of permissions, etc.) please file a bug:
https://github.com/devonfw/IDEasy/issues/new?assignees=&labels=bug&projects=&template=bug.md&title=java.lang.NullPointerException
java.lang.NullPointerException
        at com.devonfw.tools.ide.tool.LocalToolCommandlet.install(LocalToolCommandlet.java:82)
        at com.devonfw.tools.ide.tool.ToolCommandlet.install(ToolCommandlet.java:223)
        at com.devonfw.tools.ide.commandlet.InstallCommandlet.run(InstallCommandlet.java:49)
        at com.devonfw.tools.ide.context.AbstractIdeContext.applyAndRun(AbstractIdeContext.java:862)
        at com.devonfw.tools.ide.context.AbstractIdeContext.run(AbstractIdeContext.java:771)
        at com.devonfw.tools.ide.cli.Ideasy.runOrThrow(Ideasy.java:89)
        at com.devonfw.tools.ide.cli.Ideasy.run(Ideasy.java:52)
        at com.devonfw.tools.ide.cli.Ideasy.main(Ideasy.java:29)
        at java.base@21.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)


Error: IDEasy failed with exit code 255

Steps to reproduce (bug) / Use Case of feature request (enhancement)

  1. edit your config (devon.properties or ide.properties):
MVN_VERSION=3.9.6
MAVEN_VERSION=${MVN_VERSION}
  1. ide install mvn

Related/Dependent Issues

Comments/Hints:

I hit multiple problems here. First of all MAVEN_VERSION=${MVN_VERSION} is a legacy workaround that could be used in devonfw-ide to make the configuration work also with older versions of devonfw-ide that expected MAVEN_VERSION what was changed in newer releases.
Further with #104 we implemented that the value of a variable can reference other variables including itself so ${MVN_VERSION} can be evaluated by EnvironmentVariablesResolved.
However, we also implemented variable legacy support via IdeVariableDefinition with legacy name for fallbacks:

The goal is that we can read legacy variables from devonfw-ide easily even though they may not be physically defined in any properties file by "redirecting" it from the legacy name to the new name.
To simplify variable resolution, we also consider that when loading properties and already store them under the new instead of the legacy name since otherwise we might have two variables defined for the same thing with different values (MVN_VERSION=3.9.9 and MAVEN_VERSION=3.0.0). However, if we then only use the new one for installation and processing but have template configuration files with ${MAVEN_VERSION} or $[MAVEN_VERSION], we might end up with the wrong value.

Further, a lot of edge-cases can happen here.
Assuming we have:

LEGACY_X=legacyX
NEW_X=newX
NEW_X=newX2
NEW_Y=newY
LEGACY_Y=legacyY

The expected result should be the same as for

NEW_X=newX2
NEW_Y=newY

Further while loading these strange assumed config, we should log warnings so the user gets informed that his configuration is odd and he should probably do a cleanup.
In the future we might want to add a commandlet to automatically cleanup all configs and migrate to IDEasy:

  • convert devon.properties to ide.properties
  • remove legacy variables and only have new/official variables
  • convert curly variable syntax for supported variables in all templates to bracket variable syntax (in combination ${DEVON_IDE_HOME} -> $[IDE_HOME]).
  • etc.

Affected version:

  • 2024.11.001-beta-SNAPSHOT

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions