Tycho: Bundle X - Missing Constraint: Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Asked Answered
C

2

5

I have changed the BREE from JavaSE-1.6 to JavaSE-1.7 in the manifest files of my application:

Bundle-RequiredExecutionEnvironment: JavaSE-1.7

Now I can not compile the application again.

When I run mvn clean install I get:

[INFO] Resolving dependencies of MavenProject: Xgroup:X:4.0.100-SNAPSHOT @ C:\Users\....\X\pom.xml
[WARNING] The following locally built units have been used to resolve project dependencies:
[WARNING]   Za
[WARNING]   Zb
[INFO] Resolving class path of MavenProject: Xgroup:X:4.0.100-SNAPSHOT @ C:\Users\....\X\pom.xml
[ERROR] Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle X cannot be resolved
[ERROR] Resolution errors:
[ERROR] Bundle X - Missing Constraint: Bundle-RequiredExecutionEnvironment: JavaSE-1.7
[ERROR] -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle X cannot be resolved
Resolution errors:
   Bundle X - Missing Constraint: Bundle-RequiredExecutionEnvironment: JavaSE-1.7

My toolchains.xml contains:

  <toolchain>
     <type>jdk</type>
     <provides>
         <version>1.7</version>
         <vendor>sun</vendor>
         <id>JavaSE-1.7</id>
     </provides>
     <configuration>
        <jdkHome>C:\Java\jdk1.7.0_45</jdkHome>
     </configuration>
  </toolchain>

When I run mvn -version the Java version seems to be OK:

Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: C:\Tools\apache-maven-3.0.4\bin\..
Java version: 1.7.0_17, vendor: Oracle Corporation
Java home: C:\Java\jdk1.7.0_17\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

I guess my JAVA_HOME is correct, but I am not sure. echo %JAVA_HOME% prints C:\Java\jdk1.7.0_17\jre. A related problem on the Tycho-Mailing list was solved by setting JAVA_HOME correctly, but my problem seems to be different.

I'm using Tycho in version 0.19.0. I have also tried a newer version, but this didn't change anything.

Claudine answered 13/10, 2014 at 20:39 Comment(1)
Excellent question BTW! Thanks for extending the log snippet, this makes it even more useful for future readers :-)Depolymerize
D
8

Have a close look into the log message - it is not unlikely that you get the error message

[ERROR] Bundle X - Missing Constraint: Bundle-RequiredExecutionEnvironment: JavaSE-1.7

while Tycho resolves dependencies and the compile class path of a different bundle project Y which depends on bundle X. Find the last one of the following log messages prior to the error:

[INFO] Resolving class path of MavenProject: ...

This line shows which project has the resolution problem.


If the failing project is in fact a different bundle Y which depends on bundle X, you should check the Bundle-RequiredExecutionEnvironment header of bundle Y: If bundle Y declares e.g. a BREE of JavaSE-1.6, it is expected that the build fails. The reason for this is as follows: Unless configured otherwise, Tycho assumes that you want to run bundle Y in OSGi container that provides the execution environment specified in the BREE header. In the example this would be an OSGi container on a JavaSE-1.6 VM. However in such a container, Y could not be started because it depends on X which can not be started. This is what Tycho detects and why the build fails.

You can deal with this situation in different ways:

  • Also change the BREE header of bundle Y. This in particular makes sense if you know that Y will will anyway always run together with the version of bundle X which requires JavaSE-1.7.

  • Configure the execution environment for bundle Y separately from the BREE header, e.g. via the executionEnvironment target platform configuration (not recommended). This may also change the JRE that bundle Y is compiled for, so bundle Y may then in fact no longer run on Java 6. So only use this option if you fully understand the implications of the execution environment on the build.

  • Disable Tycho's checks for execution environment constraints by setting the target platform configuration parameter resolveWithExecutionEnvironmentConstraints to false (since Tycho 0.22.0). This may make sense if your bundle Y may run with a completely different version or implementation of bundle X than the version you use at compile time.


If the failing project is the bundle X project itself, there is some configuration in the (parent) POM or the build.properties which makes Tycho use a different, lower execution envirionment than the one specified in the Bundle-RequiredExecutionEnvironment header of bundle X (see documentation on the execution environment configuration for details). You should probably remove this conflicting, redundant configuration.

Depolymerize answered 14/10, 2014 at 10:2 Comment(1)
Thank you. Your note about the build.properties makes me check this. I had: jre.compilation.profile = JavaSE-1.6 in my project. Changing this to JavaSE-1.7 fix my problem.Claudine
P
1

is it possible you configured a different execution environment in pom.xml (possibly inherited from parent pom)? See

https://wiki.eclipse.org/Tycho/Execution_Environments#Execution_environment_configuration

Papule answered 14/10, 2014 at 7:8 Comment(1)
Thank you for the link, it contains the solution to my problem. The answer provided by @Depolymerize contains more explanations, this is why I selected it.Claudine

© 2022 - 2024 — McMap. All rights reserved.