mavenosgieclipse-rcptychojava-21

Unknown OSGi execution environment: 'JavaSE-21'


I try to upgrade an Eclipse RCP project from Java 17 o Java 21. The project is currently using Eclipse Target Platform 2023-12.

2023-12.target

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="Retrospective (2023-12)">
    <locations>
        <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
            <repository location="http://download.eclipse.org/releases/2023-12/"/>
            <unit id="org.eclipse.equinox.sdk.feature.group" version="0.0.0"/>
            <unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
        </location>
    </locations>
</target>

pom.xml

...
<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-maven-plugin</artifactId>
    <version>${tycho-version}</version>
    <extensions>true</extensions>
</plugin>
<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>target-platform-configuration</artifactId>
    <version>${tycho-version}</version>
    <configuration>
        <resolver>p2</resolver>
        <target>
            <artifact>
                <groupId>com.retrospective</groupId>
                <artifactId>com.retrospective.target</artifactId>
                <version>6.2.0</version>
                <classifier>2023-12</classifier>
            </artifact>
        </target>
        ...

What I did so far:

When I push my changes to GIT, the CI/CD build job starts but produces an error. I can reproduce the same error when running mvn clean verify -e locally:

Unknown OSGi execution environment: 'JavaSE-21'
org.eclipse.tycho.core.ee.UnknownEnvironmentException: Unknown OSGi execution environment: 'JavaSE-21'
    at org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils.getExecutionEnvironment (ExecutionEnvironmentUtils.java:102)
    at org.eclipse.tycho.core.osgitools.OsgiBundleProject.applyBestOfCurrentOrConfiguredProfile (OsgiBundleProject.java:642)
    at org.eclipse.tycho.core.osgitools.OsgiBundleProject.readExecutionEnvironmentConfiguration (OsgiBundleProject.java:617)
    at org.eclipse.tycho.core.TychoProjectManager.lambda$getExecutionEnvironmentConfiguration$0 (TychoProjectManager.java:118)
    at org.eclipse.tycho.core.osgitools.DefaultReactorProject$LazyValue.get (DefaultReactorProject.java:307)
    at org.eclipse.tycho.core.osgitools.DefaultReactorProject.computeContextValue (DefaultReactorProject.java:200)
    at org.eclipse.tycho.core.TychoProjectManager.getExecutionEnvironmentConfiguration (TychoProjectManager.java:112)
    at org.eclipse.tycho.p2resolver.P2DependencyResolver.lambda$getPreliminaryTargetPlatform$3 (P2DependencyResolver.java:214)
    at org.eclipse.tycho.core.osgitools.DefaultReactorProject$LazyValue.get (DefaultReactorProject.java:307)
    at org.eclipse.tycho.core.osgitools.DefaultReactorProject.computeContextValue (DefaultReactorProject.java:200)
    at org.eclipse.tycho.p2resolver.P2DependencyResolver.getPreliminaryTargetPlatform (P2DependencyResolver.java:209)
    at org.eclipse.tycho.core.osgitools.AbstractTychoProject.lambda$getDependencyArtifacts$0 (AbstractTychoProject.java:83)
    at org.eclipse.tycho.core.osgitools.DefaultReactorProject$LazyValue.get (DefaultReactorProject.java:307)
    at org.eclipse.tycho.core.osgitools.DefaultReactorProject.computeContextValue (DefaultReactorProject.java:200)
    at org.eclipse.tycho.core.osgitools.AbstractTychoProject.getDependencyArtifacts (AbstractTychoProject.java:77)
    at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject (DefaultTychoResolver.java:98)
    at org.eclipse.tycho.core.maven.TychoProjectExecutionListener.beforeProjectLifecycleExecution (TychoProjectExecutionListener.java:111)
    at org.apache.maven.lifecycle.internal.CompoundProjectExecutionListener.beforeProjectLifecycleExecution (CompoundProjectExecutionListener.java:42)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:103)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    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.main (MavenCli.java:206)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)

Which important migration step have I forgotten?


Solution

  • Make sure to run your CI/CD Maven build with Java 21.

    To get the version of Maven and Java at the beginning of the log, use the Maven command line option -V or --show-version.

    In general, for CI/CD Maven builds the following options might be helpful: