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

WST unable to update Maven configuration: Version 8 of project facet java does not exist. #26

Open
garretwilson opened this issue Jun 7, 2023 · 17 comments
Labels
bug Something isn't working

Comments

@garretwilson
Copy link

garretwilson commented Jun 7, 2023

I upgraded to Eclipse EE 2023-06 RC1 (4.28.0 RC1) on Windows 10 and things started breaking. (This issue was first reported at eclipse-m2e/m2e-core#1414 but I was told that this is related to WST.)

In my long-running https://github.com/globalmentor/globalmentor-root project I have a pom.xml for Java 8 with the following line:

<maven.compiler.release>8</maven.compiler.release> <!-- JDK 9+ required to build -->

The correct value for <maven.compiler.release> is 8. See Setting the --release of the Java Compiler.

This is a Java compiler 9+ option (why it's needed is a long story), but there shouldn't be any problem with that. I'll just use a JDK version 9+ when building. And in fact in Eclipse I have the following JRE registered:

openjdk 17.0.4 2022-07-19
OpenJDK Runtime Environment Temurin-17.0.4+8 (build 17.0.4+8)
OpenJDK 64-Bit Server VM Temurin-17.0.4+8 (build 17.0.4+8, mixed mode, sharing)

I have another project https://github.com/globalmentor/globalmentor-base which uses globalmentor-root as its parent. In Eclipse EE 2023-06 if I try to refresh the project using Alt+F5, it tells me:

Unable to update Maven configuration
Could not update project globalmentor-management configuration
Version 8 of project facet java does not exist.
Could not update project globalmentor-core configuration
Version 8 of project facet java does not exist.

What does that mean? It has something to do with <maven.compiler.release>8</maven.compiler.release> in the globalmentor-root project, because if I change it to <maven.compiler.release>11/maven.compiler.release>, then suddenly I can refresh globalmentor-base.

But I want to release those two libraries for Java 8, not Java 11. It shouldn't matter that a JDK 9+ is required to build it.

Are you suddenly using the <maven.compiler.release>8/maven.compiler.release> to restrict the JDK used to build the project? The maven.compiler.release flag is to determine the target API, not to restrict the JDK being used to build the project. See JEP 247: Compile for Older Platform Versions.

Note that I have both globalmentor-root and globalmentor-base in my workspace, both set to -SNAPSHOT versions (minor upgrades).

This was working on Eclipse 2023-3 and for years earlier. If I can't find a way around this I'm going to have to roll back.

Here's a stack trace. Interestingly it mentions globalmentor-core and globalmentor-management, which are subprojects of globalmentor-base:

!ENTRY org.eclipse.m2e.core.ui 4 -1 2023-06-06 10:39:34.546
!MESSAGE Unable to update Maven configuration
!SUBENTRY 1 org.eclipse.m2e.core 4 0 2023-06-06 10:39:34.546
!MESSAGE Could not update project globalmentor-management configuration
!STACK 0
java.lang.IllegalArgumentException: Version 8 of project facet java does not exist.
	at org.eclipse.wst.common.project.facet.core.util.internal.Versionable.getVersion(Versionable.java:80)
	at org.eclipse.wst.common.project.facet.core.internal.ProjectFacet.getVersion(ProjectFacet.java:1)
	at org.eclipse.m2e.wtp.WTPProjectsUtil.installJavaFacet(WTPProjectsUtil.java:482)
	at org.eclipse.m2e.wtp.UtilityProjectConfigurator.configure(UtilityProjectConfigurator.java:65)
	at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:123)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$6(ProjectConfigurationManager.java:504)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:498)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$4(ProjectConfigurationManager.java:426)
	at java.base/java.util.Collection.removeIf(Collection.java:576)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:414)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$3(ProjectConfigurationManager.java:340)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1097)
	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)
!SUBENTRY 1 org.eclipse.m2e.core 4 0 2023-06-06 10:39:34.546
!MESSAGE Could not update project globalmentor-core configuration
!STACK 0
java.lang.IllegalArgumentException: Version 8 of project facet java does not exist.
	at org.eclipse.wst.common.project.facet.core.util.internal.Versionable.getVersion(Versionable.java:80)
	at org.eclipse.wst.common.project.facet.core.internal.ProjectFacet.getVersion(ProjectFacet.java:1)
	at org.eclipse.m2e.wtp.WTPProjectsUtil.installJavaFacet(WTPProjectsUtil.java:482)
	at org.eclipse.m2e.wtp.UtilityProjectConfigurator.configure(UtilityProjectConfigurator.java:65)
	at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:123)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$6(ProjectConfigurationManager.java:504)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:498)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$4(ProjectConfigurationManager.java:426)
	at java.base/java.util.Collection.removeIf(Collection.java:576)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:414)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$3(ProjectConfigurationManager.java:340)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1097)
	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)

Currently my workaround is:

  1. Go to globalmentor-root and set <maven.compiler.release>11/maven.compiler.release>.
  2. Go to globalmentor-base and use Alt+F5 to refresh the Maven project.
  3. Go back to globalmentor-root and set <maven.compiler.release>8/maven.compiler.release> as it was before.

Apparently this is sneaky enough that the new Eclipse doesn't notice and doesn't complain. I'll cross my fingers to see if it continues to work.

Unfortunately this means I'll need need to go through those workaround steps again if I ever need to refresh the globalmentor-base Maven project in Eclipse again.

@nitind
Copy link
Contributor

nitind commented Jun 7, 2023

WTP does not have a version "8" of its Java facet. It's always used "1.8". I can add aliases, but I don't believe this is new
behavior on our end.

@fbricon
Copy link
Contributor

fbricon commented Jun 7, 2023

So looks like this bit (100% calling WST API) :

IProjectFacetVersion javaFv = JavaFacet.FACET.getVersion(JavaFacetUtil.getCompilerLevel(project));

now returns 8 instead of 1.8. Looks like something has changed in WST. I need to investigate to understand what changed.

cc @nitind

@lrozenblyum
Copy link

lrozenblyum commented Jun 15, 2023

Hello, I'm facing the same error

!MESSAGE An internal error occurred during: "Updating Maven Project".
!STACK 0
java.lang.IllegalArgumentException: Version 8 of project facet java does not exist.
	at org.eclipse.wst.common.project.facet.core.util.internal.Versionable.getVersion(Versionable.java:80)

while all my pom.xml are specifying JDK17 as the 'release' property of maven-compiler-plugin in this way:

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <release>17</release>
                    </configuration>
                </plugin>

Wondering how is this '8' version still affecting the work, should I file a separate ticket?

@nitind
Copy link
Contributor

nitind commented Jun 15, 2023

!MESSAGE An internal error occurred during: "Updating Maven Project".
!STACK 0
java.lang.IllegalArgumentException: Version 8 of project facet java does not exist.
at org.eclipse.wst.common.project.facet.core.util.internal.Versionable.getVersion(Versionable.java:80)

Was there more to that stack trace? And was this under 2023-06?

@fbricon
Copy link
Contributor

fbricon commented Jun 15, 2023

I'm surprised you see that error if all your projects target release 17. Please provide a sample project reproducing this error.

@lrozenblyum
Copy link

@nitind

  1. It's Eclipse 2023-06 (for Java EE) +Lombok 1.8.28

  2. The full stack trace (repeated multiple times)

!ENTRY org.eclipse.core.jobs 4 2 2023-06-16 09:45:06.207
!MESSAGE An internal error occurred during: "Updating Maven Project".
!STACK 0
java.lang.IllegalArgumentException: Version 8 of project facet java does not exist.
	at org.eclipse.wst.common.project.facet.core.util.internal.Versionable.getVersion(Versionable.java:80)
	at org.eclipse.wst.common.project.facet.core.internal.ProjectFacet.getVersion(ProjectFacet.java:1)
	at org.eclipse.m2e.wtp.WTPProjectsUtil.installJavaFacet(WTPProjectsUtil.java:482)
	at org.eclipse.m2e.wtp.WTPProjectsUtil.configureWtpUtil(WTPProjectsUtil.java:727)
	at org.eclipse.m2e.wtp.AbstractProjectConfiguratorDelegate.configureWtpUtil(AbstractProjectConfiguratorDelegate.java:117)
	at org.eclipse.m2e.wtp.AbstractProjectConfiguratorDelegate.preConfigureDependencyProject(AbstractProjectConfiguratorDelegate.java:166)
	at org.eclipse.m2e.wtp.EarProjectConfiguratorDelegate.setModuleDependencies(EarProjectConfiguratorDelegate.java:206)
	at org.eclipse.m2e.wtp.WTPProjectConfigurator.mavenProjectChanged(WTPProjectConfigurator.java:94)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.mavenProjectChanged(ProjectConfigurationManager.java:883)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.notifyProjectChangeListeners(ProjectRegistryManager.java:851)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.applyMutableProjectRegistry(ProjectRegistryManager.java:1004)
	at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:316)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:388)
	at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$3(ProjectConfigurationManager.java:340)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1097)
	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)

@lrozenblyum
Copy link

@fbricon I'll try to prepare a minimal test case.

@fbricon
Copy link
Contributor

fbricon commented Jun 16, 2023

Stacktrace says you have an EAR project with some lib/ dependencies, at least one of them might still be compiled using Java 8

@lrozenblyum
Copy link

@fbricon finally I got what was causing the problem.

My local M2 repo contained old versions of the artifacts of the project, which had Java8 in their pom.xml

Even though the 'Workspace resolution' is ON, it seems M2E at some point doesn't take it first from the workspace and relies on the local M2 repo.
After cleaning the M2 repo, import of all the projects succeeded.

@fbricon
Copy link
Contributor

fbricon commented Jun 16, 2023

the facet configuration only applies to workspace projects, so it should have worked

@lrozenblyum
Copy link

@fbricon maybe transitive dependencies caused that (although they're also part of the workspace...)

@alexlitovsky
Copy link

Just upgraded to eclipse 2023-06 and ran into the same issue. Ended up downgrading back to 2023-03 to be able to continue working. Eagerly watching for a fix :)

@alexlitovsky
Copy link

Here is a test case to reproduce the issue: https://bitbucket.org/alexlitovsky1/eclipse-m2e-bug/
Clone this repo and import it into eclipse as a maven project.

@fbricon
Copy link
Contributor

fbricon commented Jul 5, 2023

The fix was done in upstream m2e: eclipse-m2e/m2e-core#1414

Please try the latest m2e snapshot from this p2 repository
https://download.eclipse.org/technology/m2e/snapshots/latest/

@lrozenblyum
Copy link

@fbricon I confirm that the original problem is not reproduced anymore for me after installing M2E 2.4.100.20230705-1302 and importing Maven projects some of which have 1.8 and some - 17 Java compiler compatibility.

@garretwilson
Copy link
Author

Please try the latest m2e snapshot from this p2 repository

When updating from the snapshot repository, do I need only everything in the "Maven Integration for Eclipse" category, or also things under the "Maven Embedded Runtimes" and "Uncategorized" categories?

@mickaelistria
Copy link
Contributor

Just "Maven Integration for Eclipse" should be enough. Dependencies that need to be updated will be updated by the way.

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
None yet
Development

No branches or pull requests

6 participants