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

Uses constraint violation while upgrading from tycho 2.2 -> 2.3 #169

Closed
laeubi opened this issue Jul 3, 2021 · 20 comments
Closed

Uses constraint violation while upgrading from tycho 2.2 -> 2.3 #169

laeubi opened this issue Jul 3, 2021 · 20 comments
Labels
bug 🚨 regression Regression compared to previous release - blocks upcoming release and other merges upstream-p2
Milestone

Comments

@laeubi
Copy link
Member

laeubi commented Jul 3, 2021

I try to upgrade a build from tycho 2.2 -> 2.3 (the same happens for the current SNAPSHOT) but the build fails now with:

org.apache.felix.resolver.reason.ReasonException: Uses constraint violation. Unable to resolve resource [...a bundle from the build...] because it is exposed to package 'javax.xml.bind.annotation.adapters' from resources org.eclipse.osgi [osgi.identity; osgi.identity="org.eclipse.osgi"; type="osgi.bundle"; version:Version="3.16.300.v20210525-1715"; singleton:="true"] and jakarta.xml.bind-api [osgi.identity; osgi.identity="jakarta.xml.bind-api"; type="osgi.bundle"; version:Version="2.3.2"] via two dependency chains.

While this is something that might be resolved by tweaking the imports and use constraints, tycho seem to resolve / install conflicting bundles here, as in the runtime / product there is no issue with this as there is always only one provider for that package. The bundle itself is from an update-site so not part of the build and works with 2.3...

@mickaelistria any idea what can be the culprit here between 2.2 -> 2.3 ?

@laeubi
Copy link
Member Author

laeubi commented Jul 3, 2021

This currently prevents one using different versions of the same bundle in the same reactor build.

@laeubi
Copy link
Member Author

laeubi commented Jul 3, 2021

This currently makes it impossible to use <resolveWithExecutionEnvironmentConstraints>false</resolveWithExecutionEnvironmentConstraints> for me also. I'll try to create a minimal reproducer for this, this really is a major regression/blocker for me.

@laeubi laeubi added the 🚨 regression Regression compared to previous release - blocks upcoming release and other merges label Jul 3, 2021
@mickaelistria
Copy link
Contributor

This is definitely a consequence of usage of the "good" resolver since 2.3: https://wiki.eclipse.org/Tycho/Release_Notes/2.3#Official_Equinox_Resolver_used_for_dependency_resolution_.28stricter_and_can_produce_errors_for_split_packages.29
and this, combined with https://bugs.eclipse.org/bugs/show_bug.cgi?id=525368 can lead to such issues; or it can also highlight that this bundle is incorrect from the very beginning and that there is no satisfactory solution for the constraints with the current TP and this was not detected earlier...

@laeubi
Copy link
Member Author

laeubi commented Jul 3, 2021

Nope this is defiantly not a good solution and a major degradation from 2.2>2.3.
Having multiple versions of the same bundle in one framework is one of the keypoints of OSGi and forcing all projects to always using the latest version is a no-go. Also Split package are not an issue here...

laeubi added a commit to laeubi/tycho that referenced this issue Jul 3, 2021
@mickaelistria
Copy link
Contributor

So indeed, p2 adds multiple versions as expected, this is the content of the DependencyArtifacts

eclipse-plugin:org.apache.batik.awt.util:1.14.0.v20210324-0332: null
eclipse-plugin:org.apache.batik.constants:1.14.0.v20210324-0332: null
eclipse-plugin:org.apache.batik.constants:1.9.1.v20180227-1645: null
eclipse-plugin:org.apache.batik.css:1.14.0.v20210324-0332: null
eclipse-plugin:org.apache.batik.dom:1.14.0.v20210324-0332: null
eclipse-plugin:org.apache.batik.ext.awt:1.9.1.v20190730-1743: null
eclipse-plugin:org.apache.batik.i18n:1.14.0.v20210324-0332: null
eclipse-plugin:org.apache.batik.i18n:1.9.1.v20180227-1645: null
eclipse-plugin:org.apache.batik.svggen:1.14.0.v20210324-0332: null
eclipse-plugin:org.apache.batik.util:1.14.0.v20210324-0332: null
eclipse-plugin:org.apache.batik.util:1.9.1.v20180703-1553: null
eclipse-plugin:org.apache.batik.xml:1.14.0.v20210324-0332: null
eclipse-plugin:org.apache.commons.io:2.8.0.v20210415-0900: null
eclipse-plugin:org.apache.commons.logging:1.2.0.v20180409-1502: null
eclipse-plugin:org.apache.xalan:2.7.2.v20201124-1837: null
eclipse-plugin:org.apache.xmlgraphics:2.6.0.v20210409-0748: null
eclipse-plugin:org.eclipse.osgi:3.16.200.v20210226-1447: null
eclipse-plugin:org.w3c.css.sac:1.3.1.v200903091627: null
eclipse-plugin:org.w3c.dom.events:3.0.0.draft20060413_v201105210656: null
eclipse-plugin:org.w3c.dom.smil:1.0.1.v200903091627: null
eclipse-plugin:org.w3c.dom.svg:1.1.0.v201011041433: null
eclipse-plugin:version.bundle1:1.0.0: MavenProject: org.eclipse.tycho.its.resolver.versions:version.bundle1:1.0.0 @ /home/mistria/git/org.eclipse.tycho/tycho-its/target/projects/DifferentVersionsTest/testBundleNativeCode/resolver.differentVersions/bundle1/pom.xml

Those results are correct, or at least not incorrect, and are then passed to EquinoxResolver.

@laeubi
Copy link
Member Author

laeubi commented Jul 5, 2021

Those results are correct, or at least not incorrect

If we are talking about this particular bundle it is wrong to have two different versions (1.9.1 + 1.14.0) of the same dependency on classpath. Why do you think its fine to have both?

@mickaelistria
Copy link
Contributor

Actually, I take that back: p2 result are not satisfactory, and -without surprise- Equinox is correct here (a good approach is to assume is always correct).

eclipse-plugin:org.apache.batik.svggen:1.14.0.v20210324-0332 would actually require (via import-package) eclipse-plugin:org.apache.batik.ext.awt:1.14.0 , but p2 gives 1.9.1 without complaining.
Orbit doesn't contain org.apache.batik.ext.awt, so the bundle is not resolvable for this TP anyway. IT would be expected that the failure happen earlier (in p2).

So I do not see it as a general problem of Tycho being suddenly unable to resolve, but more as a particular issue with batik & Orbit.

@laeubi
Copy link
Member Author

laeubi commented Jul 5, 2021

eclipse-plugin:org.apache.batik.svggen:1.14.0.v20210324-0332 would actually require (via import-package) eclipse-plugin:org.apache.batik.ext.awt:1.14.0 , but p2 gives 1.9.1 without complaining.

The problem is that 1.14.0 should never be resolved but 1.9.1 is the only choice applicable here for that bundle!

Orbit doesn't contain org.apache.batik.ext.awt,

org.apache.batik.ext.awt is not available for 1.14.0 anyways its named org.apache.batik.awt.util there.

@laeubi
Copy link
Member Author

laeubi commented Jul 5, 2021

Tycho being suddenly unable to resolve

Don't know if the resolver or p2 or both trigger that change, actually it has worked before (or ignored the potentially inconsistency) and from a classpath perspective doesn't matter here. So tycho is being 'over correct' here because it sees an inconsistency on its internal p2 resolved artifacts, but these might never be occur as the runtime configuration might be different!

@mickaelistria
Copy link
Contributor

he problem is that 1.14.0 should never be resolved but 1.9.1 is the only choice applicable here for that bundle!

OK, and p2 doesn't include svggen 1.9.1 but prefer 1.14 despite incompatibility with the org.apache.batik.ext.awt 1.9.1. So this seems like the root cause, isn't it?

actually it has worked before

I think it used to be 2 errors, one in p2 sending incorrect input and another in old resolver returning false-positive, that used to balance each other and make this pass.

@laeubi
Copy link
Member Author

laeubi commented Jul 5, 2021

Hard to guess... As I have used that in a product since a while and in the end simply get both batik versions included but equinox do not complained when actually running the product there might be a solution that is not obvious here.

If I take a look at the code at org.eclipse.tycho.core.osgitools.EquinoxResolver.newState(DependencyArtifacts, Properties, MavenSession) the methods filterSingletonCollisions / filterResolvable / filterMatches are all no-ops also ModuleCollisionHook has a comment that collisions never happen... maybe this is a situation where there actually an implementation would be required to resolve the conflict?

@mickaelistria
Copy link
Contributor

As I have used that in a product since a while and in the end simply get both batik versions included but equinox do not complained when actually running the product there might be a solution that is not obvious here.

But does the product have multiple versions of svggen included (unlike the example here) ?

@laeubi
Copy link
Member Author

laeubi commented Jul 5, 2021

Running ls -1a *batik* gives the following list:

org.apache.batik.anim_1.13.0.v20201130-1756.jar
org.apache.batik.awt.util_1.13.0.v20201124-1832.jar
org.apache.batik.bridge_1.13.0.v20201124-1840.jar
org.apache.batik.constants_1.13.0.v20200622-2037.jar
org.apache.batik.constants_1.9.1.v20180227-1645.jar
org.apache.batik.css_1.13.0.v20200622-2037.jar
org.apache.batik.css_1.9.1.v20181015-1528.jar
org.apache.batik.dom_1.13.0.v20201124-1839.jar
org.apache.batik.dom_1.9.1.v20190730-1743.jar
org.apache.batik.dom.svg_1.13.0.v20201124-1839.jar
org.apache.batik.ext_1.13.0.v20201124-1832.jar
org.apache.batik.ext.awt_1.9.1.v20190730-1743.jar
org.apache.batik.gvt_1.13.0.v20201124-1835.jar
org.apache.batik.i18n_1.13.0.v20200622-2037.jar
org.apache.batik.i18n_1.9.1.v20180227-1645.jar
org.apache.batik.parser_1.13.0.v20201124-1833.jar
org.apache.batik.script_1.13.0.v20201124-1840.jar
org.apache.batik.svggen_1.13.0.v20201124-1836.jar
org.apache.batik.svggen_1.9.1.v20190730-1743.jar
org.apache.batik.transcoder_1.13.0.v20201124-1841.jar
org.apache.batik.util_1.13.0.v20200622-2037.jar
org.apache.batik.util_1.9.1.v20180703-1553.jar
org.apache.batik.xml_1.13.0.v20201124-1831.jar
org.apache.batik.xml_1.9.1.v20190730-1743.jar

If I rember correctly we have tweaked two features that include explicit versions of bundles so not 0.0.0 but for example 1.9.1.v20190730-1743 in the feature.xml. That features are then included in a product together with the bundles importing them via require bundle.

@mickaelistria
Copy link
Contributor

If I rember correctly we have tweaked two features that include explicit versions of bundles so not 0.0.0 but for example 1.9.1.v20190730-1743 in the feature.xml. That features are then included in a product together with the bundles importing them via require bundle.

OK, so it seems like you were already facing the issue of p2 not properly resolving batik bundles, and you implemented a workaround for it by adding constraints (narrower version ranges) to p2 resolver to ensure you get the right one.

@laeubi
Copy link
Member Author

laeubi commented Jul 5, 2021

The problem was/is that tycho only resolves "to latest" when using 0.0.0 so we have one feature for the 1.9.1 and one for the 1.13.0 version of batik. Both features are then used (mostly because platform used 'old' batik for but our application needs the never one). So to summarize, it seems possible to run/resolve both versions in the same framework nerveless if P2 resolves too much here.

@mickaelistria
Copy link
Contributor

The problem was/is that tycho only resolves "to latest" when using 0.0.0

Not Tycho, but p2.
Not necessarily to latest, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=352560 and duplicates.
p2 is by design, expectations and goal supposed to return a valid plan first, whatever it choses should be good. The fact that it returns an invalid plan is a bug in p2. I believe this particular case if caused by "optional' that leads to some constraints being ignored.

So to summarize, it seems possible to run/resolve both versions in the same framework nerveless if P2 resolves too much here.

Yes, it definitely is possible to have multiple (complete) versions of batik. The issue here is not that there is too much stuff in p2 resolution, but instead that something is missing to build a good dependency set, in particular org.apache.batik.svggen 1.9.1.
One way to achieve that is similar to what you've already done for your product/features: add extra constraints that make p2 do a better job and not fall into a bugged case. That can be for example Require-Bundle: org.apache.batik.svggen;bundle-version="[1.7.0,1.10.0)" or

	<build>
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>target-platform-configuration</artifactId>
				<version>2.4.0-SNAPSHOT</version>
				<configuration>
					<dependency-resolution>
						<extraRequirements>
							<requirement>
								<type>p2-installable-unit</type>
								<id>org.apache.batik.svggen</id>
								<versionRange>[1.7.0,1.10.0)</versionRange>
							</requirement>
						</extraRequirements>
					</dependency-resolution>
				</configuration>
			</plugin>
		</plugins>
	</build>

Please report the issue upstream to p2.

@laeubi
Copy link
Member Author

laeubi commented Jul 5, 2021

I'll try to enhance the example as much as possible (with feature+product) but from a users perspective this is clearly tycho not behave as expected.

I'm not sure if I would be able to describe what the actual bug in P2 is here ... and I still think that this is "too much" as from a resolving perspective the versions > 1.9.1 are useless as the bundle itself can't ever use them, so I would expect that P2 ever only install the version that satisfy this bundle or do I get something wrong here?

@laeubi
Copy link
Member Author

laeubi commented Jul 5, 2021

BTW the problem is not that one could tweak the manifest or features or config but that a working build fails due to (unused) additional items in the target (like with the justj) in this case a newer batik version.

laeubi added a commit to laeubi/tycho that referenced this issue Jul 5, 2021
@mickaelistria
Copy link
Contributor

I'm not sure if I would be able to describe what the actual bug in P2 is here ... and I still think that this is "too much" as from a resolving perspective the versions > 1.9.1 are useless as the bundle itself can't ever use them, so I would expect that P2 ever only install the version that satisfy this bundle or do I get something wrong here?

Yes, that's the idea. In that case, p2 should choose 1.9.1 only and not include anything 1.14.0.

@laeubi
Copy link
Member Author

laeubi commented Jan 10, 2022

I'll close this for now as it is not relevant for me anymore and no one else seems to complain.

@laeubi laeubi closed this as completed Jan 10, 2022
@laeubi laeubi added this to the 2.7 milestone Feb 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🚨 regression Regression compared to previous release - blocks upcoming release and other merges upstream-p2
Projects
None yet
Development

No branches or pull requests

2 participants