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

Cannot invoke "org.apache.maven.artifact.versioning.VersionRange.getRecommendedVersion()" because "vr" is null #1103

Closed
w6et opened this issue Nov 30, 2022 · 8 comments · Fixed by #1105

Comments

@w6et
Copy link

w6et commented Nov 30, 2022

sts4 4.16.1
Unable to update Maven configuration
Could not update project ##{{project.name}}## configuration
Cannot invoke "org.apache.maven.artifact.versioning.VersionRange.getRecommendedVersion()" because "vr" is null

@mickaelistria
Copy link
Contributor

Can you provide minimal steps to reproduce?

@w6et
Copy link
Author

w6et commented Nov 30, 2022

after upgrade m2e 2.1.1,Looks like occured in multiple project:
project A is a bom project(has multiple moudle)
project B is a code project(has multiple moudle)
when i selected two projects,Right-click-->Maven-->Update Project,the exception occured。
BTW:Two projects's jars under local repo,not in remote repo(just mvn install to local repo)
local maven version is 3.8.6
@mickaelistria

@HannesWell
Copy link
Contributor

This is probably a Regression from #981.

My guess at the phone is that you have the enforcer-plugin configured but without a required requireJavaVersion rule and therefore a null version is passend to getMinimumJavaBuildEnvironmentId(String).

I can provider a patch this this evening.
Nevertheless a Stacktrace of the Error would be good for confirmation.

@pikus
Copy link

pikus commented Nov 30, 2022

Hi!
Here it is:

!MESSAGE Could not update project xxxxxxx configuration
!STACK 0
java.lang.NullPointerException: Cannot invoke "org.apache.maven.artifact.versioning.VersionRange.getRecommendedVersion()" because "vr" is null
        at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getMinimumJavaBuildEnvironmentId(AbstractJavaProjectConfigurator.java:870)
        at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getMinimumJavaBuildEnvironmentId(AbstractJavaProjectConfigurator.java:865)
        at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getMinimumJavaBuildEnvironmentId(AbstractJavaProjectConfigurator.java:849)
        at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.configure(AbstractJavaProjectConfigurator.java:174)
        at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:123)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$6(ProjectConfigurationManager.java:494)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:364)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:274)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:488)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$4(ProjectConfigurationManager.java:416)
        at java.base/java.util.Collection.removeIf(Collection.java:576)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:410)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$3(ProjectConfigurationManager.java:340)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:364)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:274)
        at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:213)
        at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1102)
        at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:339)
        at org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob.runInWorkspace(UpdateMavenProjectJob.java:80)
        at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

@w6et
Copy link
Author

w6et commented Nov 30, 2022

This is probably a Regression from #981.

My guess at the phone is that you have the enforcer-plugin configured but without a required requireJavaVersion rule and therefore a null version is passend to getMinimumJavaBuildEnvironmentId(String).

I can provider a patch this this evening. Nevertheless a Stacktrace of the Error would be good for confirmation.

you're right,I have enforcer-plugin,but without requireJavaVersion,fix this,the problem looks ok。

@HannesWell
Copy link
Contributor

Thanks, Looks as expected

Probably a simple null check before AbstractJavaProjectConfigurator.getMinimumJavaBuildEnvironmentId(AbstractJavaProjectConfigurator.java:865) will do the Job:

if(version == null) {
      return null;
    }

@wsw186 would you bei interesesed to provide a PR to fix this? If not, I can do it.

@w6et
Copy link
Author

w6et commented Nov 30, 2022

After reading CONTRIBUTING.md, I have no 'Eclipse Foundation account' yet and am not familiar with the process, Maybe you can do it first. @HannesWell 😅

HannesWell added a commit to HannesWell/m2e-core that referenced this issue Nov 30, 2022
Fixes eclipse-m2e#1103

And rename JavaConfigurationFromEnforcer to
JavaConfigurationFromEnforcerTest to enable it in the CI.
HannesWell added a commit to HannesWell/m2e-core that referenced this issue Nov 30, 2022
Fixes eclipse-m2e#1103

And rename JavaConfigurationFromEnforcer to
JavaConfigurationFromEnforcerTest to enable it in the CI.
@HannesWell
Copy link
Contributor

I was able to reproduce the issue as expected and created #1105 to fix it and add a test-case to ensure it won't happen again in the future.

After reading CONTRIBUTING.md, I have no 'Eclipse Foundation account' yet and am not familiar with the process, Maybe you can do it first. @HannesWell 😅

No problem. This initial legal process indeed takes a few minutes but after you have created a Eclipse Foundation account and signed the ECA everything else should be relatively simple given you are familiar with Eclipse and Github. The Oomph setup should completely automate the setup of you m2e workspace and after it has succeeded you should be ready to code. Push the changes to your m2e-fork and create a PR from that.
We committers will then help you with all further procedures and assist you if you get stuck somewhere.

I now did this because I want to have this fixed soon to create a bug-fix release this evening, but in general we welcome quality contributes very much and if you are interested I recommend you to start with small changes to get familiar with the process. :)

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

Successfully merging a pull request may close this issue.

4 participants