Bug 539637 - Launch configuration doesn't find plugin when there are two versions
Summary: Launch configuration doesn't find plugin when there are two versions
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.9   Edit
Hardware: PC Windows 8
: P3 major with 3 votes (vote)
Target Milestone: 4.22 M1   Edit
Assignee: Hannes Wellmann CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
: 496549 548429 (view as bug list)
Depends on:
Blocks: 570760
  Show dependency tree
 
Reported: 2018-09-28 14:00 EDT by Claudia Irvine CLA
Modified: 2021-10-09 04:36 EDT (History)
9 users (show)

See Also:


Attachments
Simple test case to demonstrate the issue. (6.87 KB, application/x-zip-compressed)
2018-12-06 11:05 EST, Don Purnhagen CLA
no flags Details
Adding all bundles for the same id can cause problems (1.39 KB, patch)
2019-06-26 08:36 EDT, Vikas Chandra CLA
no flags Details | Diff
Large mixed benchmark test case (2.56 KB, application/x-zip-compressed)
2021-09-23 17:29 EDT, Hannes Wellmann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Claudia Irvine CLA 2018-09-28 14:00:41 EDT
The launch configuration validation returns missing constraint when there are two versions of the same plug-in.

Looks like a previous bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=472778) but the patch appears in the source code.

I am using version 2018-09(4.9) build I20180906-0745.

Steps to reproduce:
Install the SDK package.
Install new software from Sirius site (http://download.eclipse.org/sirius/updates/releases/6.0.2/photon/) and select Sirius Integration with EEF.
In run config, launch with features on Plug-ins tab. Deselect all and select org.eclipse.sirius.runtime.ide.eef.
When clicking validate plug-ins, you get lots of missing constraints on org.apache.batik.

For example, under org.eclipse.sirius.diagram.ui, missing constraint 
org.apache.batik.util; bundle-version="[1.6.0,1.8.0).

org.apache.batik.util 1.6.0 and 1.10.0 are both present.
Comment 1 Don Purnhagen CLA 2018-12-04 14:28:40 EST
This issue is preventing us from moving our application past Oxygen. We would really like to get moved onto SimRel. But we can not debug our application in SimRel due to a failing validation. We can also not build it using export as a product from PDE. I am not sure if we could build using another method, such as Tycho, but we currently use the export as a product wizard from the product configuration editor.

The plug-ins that most often appear as dependencies with differing versions are the various org.apache.batik.*.
Comment 2 Andrey Loskutov CLA 2018-12-04 14:38:18 EST
It would help if you could provide a simple bundle example with a simple launch config showing the problem.

Please note that if singleton bundle with different versions is available, the smaller version will not be resolved (I guess) because only higher can be used, and it is not a bug.
Comment 3 Claudia Irvine CLA 2018-12-04 14:45:00 EST
(In reply to Andrey Loskutov from comment #2)
> It would help if you could provide a simple bundle example with a simple
> launch config showing the problem.
> 
> Please note that if singleton bundle with different versions is available,
> the smaller version will not be resolved (I guess) because only higher can
> be used, and it is not a bug.

I added a use case in the original comment. If you need something further, please explain.

The batik plugins are not singletons.
Comment 4 Andrey Loskutov CLA 2018-12-04 14:52:05 EST
A simple example which does not require any additional software to be installed.  Like a simple project, a target and a launch file. Something one can try and debug in few seconds, without fiddling with hundreds of indirect dependencies etc.
Comment 5 Don Purnhagen CLA 2018-12-06 11:05:53 EST
Created attachment 276849 [details]
Simple test case to demonstrate the issue.

Install SimRel: eclipse-committers-2018-09-win32-x86_64

Note that the plug-ins folder contains 2 versions of com.google.guava:
    com.google.guava_15.0.0.v201403281430.jar
    com.google.guava_21.0.0.v20170206-1425.jar

I found that plug-in org.eclipse.buildship.core has a dependency on [15.0.0,16.0.0), while plug-in org.eclipse.m2e.core has a dependency on [21.0,22.0).

I built a simple plug-in and product (import the attached test case as an existing project). For the included launch configuration, I specify the two features that have dependencies on different versions of com.google.guava. This launch configuration can be imported from the test case project. I then selected the button on the Plug-ins tab of the run configuration to "Select Required". Now, try to validate the run configuration. The earlier version of com.google.guava is reported as "missing".

I realize that this simple case can be "fixed" by adding bother versions of the com.google.guava plug-in from the "Add Plugins..." button, but this solution quickly becomes unmanageable when the list of plug-ins with multiple versions grows large.
Comment 6 Andrey Loskutov CLA 2019-06-19 14:26:45 EDT
*** Bug 548429 has been marked as a duplicate of this bug. ***
Comment 7 Don Purnhagen CLA 2019-06-20 08:36:33 EDT
Since a new bug, 548429, was closed as a duplicate of this one, can we bump this one and get somebody to look at it.

This issue has been complicating our debugging efforts for a long time.

Thanks!
Comment 8 Vikas Chandra CLA 2019-06-21 01:16:56 EDT
I have triaged this to 4.13M1 so that this gets more importance.
Comment 9 Vikas Chandra CLA 2019-06-26 08:36:43 EDT
Created attachment 279097 [details]
Adding all bundles for the same id can cause problems

In features like org.eclipse.ecf.filetransfer.httpclient45.feature.
Comment 10 Julian Honnen CLA 2019-06-26 09:16:38 EDT
(In reply to Vikas Chandra from comment #9)
> Created attachment 279097 [details]
> Adding all bundles for the same id can cause problems
> 
> In features like org.eclipse.ecf.filetransfer.httpclient45.feature.

Can we detect that distinct bundle versions are actually required (like in the guava example)?
Comment 11 Vikas Chandra CLA 2019-06-27 00:10:54 EDT
(In reply to Julian Honnen from comment #10)
> (In reply to Vikas Chandra from comment #9)
> > Created attachment 279097 [details]
> > Adding all bundles for the same id can cause problems
> > 
> > In features like org.eclipse.ecf.filetransfer.httpclient45.feature.
> 
> Can we detect that distinct bundle versions are actually required (like in
> the guava example)?

We have a 			Set<String> additionalIds = DependencyManager.getDependencies(launchPlugins.toArray(), false, null);


which gives the ids. If we could also have got  the version, this would have been fixed effectively.
Comment 12 Julian Honnen CLA 2019-06-27 02:49:47 EDT
(In reply to Vikas Chandra from comment #11)
> If we could also have got  the version, this would have
> been fixed effectively.

I'll try that.
Comment 13 Julian Honnen CLA 2019-07-02 05:09:49 EDT
I won't get to it this week.
Comment 14 Vikas Chandra CLA 2019-08-14 01:19:13 EDT
Hi Julian,

Any chances of a fix by 4.13M3 ( end of this week)?
Comment 15 Julian Honnen CLA 2019-08-14 02:18:28 EDT
(In reply to Vikas Chandra from comment #14)
> Hi Julian,
> 
> Any chances of a fix by 4.13M3 ( end of this week)?

No. I played around with the dependency calculation a bit, but didn't get much further.

IMO we should replace the getDependencies implementation with a State based one. Essentially we should run the BundleValidationOperation and then add bundles that satisfy its ResolverErrors.

Other than that, I found that multiple bundle versionw work fine in a feature-based launch when the features specify the required versions explicitly.
Comment 16 Andreas Herkner CLA 2019-09-25 04:16:00 EDT
see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=481214#c1

The problem still exists in 4.13
Comment 17 Julian Honnen CLA 2020-01-23 02:55:04 EST
*** Bug 496549 has been marked as a duplicate of this bug. ***
Comment 18 Karsten Thoms CLA 2020-01-23 03:07:00 EST
Lowering severity, this is not a blocker.
Comment 19 Andreas Herkner CLA 2020-01-23 03:14:00 EST
(In reply to Karsten Thoms from comment #18)
> Lowering severity, this is not a blocker.

In my opinion, this is a blocker, since there is no workaround to run a JUnit plug-in test with two bundles require e.g. com.google.guava in different versions (or I do not really know a workaround).
Comment 20 Karsten Thoms CLA 2020-01-23 03:28:06 EST
It is preventing a specific use case and surely should be solved. It would be a blocker when no workaround is possible. The workaround is to have a clean target platform with a single version of a bundle and depending bundles that use the installed version.
Comment 21 Andreas Herkner CLA 2020-01-23 03:36:16 EST
Using a bundle in more than one version is pure OSGi. I don't think, this is a special use case.

But however, I agree to you, this should be fixed :)
Comment 22 Hannes Wellmann CLA 2021-07-27 09:59:16 EDT
(In reply to Vikas Chandra from comment #11)
> We have a 			Set<String> additionalIds =
> DependencyManager.getDependencies(launchPlugins.toArray(), false, null);
> 
> 
> which gives the ids. If we could also have got  the version, this would have
> been fixed effectively.

From all I have seen in the code yet, I think this is the solution and I offer to implement it.

My first attempt would be use NameVersionDescriptor, just because it seems to be a light weight container-class that matches all needs. But if something else more suitable exists, please let me know.

However I wonder if it wouldn't be suitable and convenient to return a Set<IPluginModelBase> (or similar) directly. In most use-cases of the DependencyManager the PluginRegistry is queried any ways for corresponding models and they are already used inside the DependencyManager. So this could avoid copying date back and forth.

If there are not objects, I try to implement a solution based on the second approach.
Comment 23 Julian Honnen CLA 2021-07-27 10:36:20 EDT
(In reply to Hannes Wellmann from comment #22)
Could you please also look into my idea from comment 15? 
Reimplementing OSGi's dependency resolution will always be lacking in some respect, e.g. with Require-Capability from bug 496549.
Comment 24 Hannes Wellmann CLA 2021-07-27 10:57:43 EDT
(In reply to Julian Honnen from comment #23)
> (In reply to Hannes Wellmann from comment #22)
> Could you please also look into my idea from comment 15? 
> Reimplementing OSGi's dependency resolution will always be lacking in some
> respect, e.g. with Require-Capability from bug 496549.

Yes, I will also consider an implementation based on the osgi.service.resolver.State.
Comment 25 Hannes Wellmann CLA 2021-07-29 06:00:55 EDT
The submitted solution for this bug is not exactly State based, but State.getDependencyClosure() gave me the idea to implement the dependency computation based on an exhaustive Breadth-first search to find the self contained closure of all required wires of the initially given set of plug-in models.

This has the following advantages:
+ the algorithm works on a more abstract level and can thus be simpler
+ the runtime and its behaviour is better (linear to the number of required wires) compared to before(previously it was iterated over all available bundles per ResolverError).

Of course computed Set of required bundles now also considers the version. This is reflected by the fact that instead of a Set of bundle id strings a Set of BundleDescriptions is returned now.
I have adapted the callers to this change. In some cases I did not use the returned BundleDescription directly because the caller have their own logic if workspace or external plug-ins should be preferred.
These are namely:
- ApiBaselineManager
- BundleLauncherHelper
- TargetContentsGroup
This could be improved in follow up changes to be more accurate.


Since the (internal) API of DependencyManager was changed any ways, I also clean it up and reworked it to be collection based and strongly typed.

Furthermore the returned Set is now a HashSet and therefore not sorted. Callers that require a SortedSet have to sort the result by themself. I think there is no need to slow down the dependency computation in all cases just because some require a sorted result.
I have checked the callers and only the ApiBaselineManager could require it. But I'm not sure about that.
Comment 26 Eclipse Genie CLA 2021-07-29 06:01:19 EDT
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/183468
Comment 27 Julian Honnen CLA 2021-07-29 08:39:02 EDT
I like the direction, thanks!
I will review and test it next week, but I'd feel more comfortable merging it first thing in 4.22 so we have the full release to find potential regressions.
Comment 28 Hannes Wellmann CLA 2021-07-29 09:05:37 EDT
(In reply to Julian Honnen from comment #27)
> I like the direction, thanks!
> I will review and test it next week, but I'd feel more comfortable merging
> it first thing in 4.22 so we have the full release to find potential
> regressions.

That's reasonable.
I'm on vacation for the first one and a half week of August, so my reply will be delayed.

However, in the meantime until the 4.21 release I will just continue with the other depended bugs and create corresponding follow-up changes in gerrit.
Comment 29 Hannes Wellmann CLA 2021-09-23 17:29:32 EDT
Created attachment 287201 [details]
Large mixed benchmark test case

As requested in Gerrit I add a relatively large mixed benchmark/demo test case.
Comment 31 Julian Honnen CLA 2021-09-27 05:02:50 EDT
Thanks a lot, Hannes!
Comment 32 Vikas Chandra CLA 2021-09-28 03:16:57 EDT
Hannes, can you please verify this fix in an I build
Comment 33 Andrey Loskutov CLA 2021-09-28 03:32:09 EDT
(In reply to Vikas Chandra from comment #32)
> Hannes, can you please verify this fix in an I build

Unfortunately we have a regression in all platforms.

https://download.eclipse.org/eclipse/downloads/drops4/I20210927-1800/testresults/html/org.eclipse.pde.ui.tests_ep422I-unit-cen64-gtk3-java11_linux.gtk.x86_64_11.html


org.eclipse.pde.core.tests.internal.DependencyManagerTest	testFindRequirementsClosure_RequireBundle2	Failure	Target resolution failed: Status ERROR: org.eclipse.pde.core code=0 Problems occurred while resolving the target contents children=[Status ERROR: org.eclipse.pde.core code=0 Problems loading repositories children=[Status ERROR: org.eclipse.pde.core code=0 Problems loading repositories children=[Status ERROR: org.eclipse.equinox.p2.metadata.repository code=1000 No repository found at file:///home/jenkins/agent/workspace/ep422I-unit-cen64-gtk3-java11/workarea/I20210927-1800/eclipse-testing/test-eclipse/eclipse/tests/sites/site.a.b.]]]

java.lang.AssertionError: Target resolution failed: Status ERROR: org.eclipse.pde.core code=0 Problems occurred while resolving the target contents children=[Status ERROR: org.eclipse.pde.core code=0 Problems loading repositories children=[Status ERROR: org.eclipse.pde.core code=0 Problems loading repositories children=[Status ERROR: org.eclipse.equinox.p2.metadata.repository code=1000 No repository found at file:///home/jenkins/agent/workspace/ep422I-unit-cen64-gtk3-java11/workarea/I20210927-1800/eclipse-testing/test-eclipse/eclipse/tests/sites/site.a.b.]]]
at org.eclipse.pde.core.tests.internal.DependencyManagerTest.createTPState(DependencyManagerTest.java:157)
at org.eclipse.pde.core.tests.internal.DependencyManagerTest.testFindRequirementsClosure_RequireBundle2(DependencyManagerTest.java:59)
Comment 34 Hannes Wellmann CLA 2021-09-28 03:39:34 EDT
(In reply to Andrey Loskutov from comment #33)
> (In reply to Vikas Chandra from comment #32)
> > Hannes, can you please verify this fix in an I build
> 
> Unfortunately we have a regression in all platforms.
> 
> https://download.eclipse.org/eclipse/downloads/drops4/I20210927-1800/
> testresults/html/org.eclipse.pde.ui.tests_ep422I-unit-cen64-gtk3-
> java11_linux.gtk.x86_64_11.html
> 
> 
> org.eclipse.pde.core.tests.internal.DependencyManagerTest
> testFindRequirementsClosure_RequireBundle2	Failure	Target resolution failed:
> Status ERROR: org.eclipse.pde.core code=0 Problems occurred while resolving
> the target contents children=[Status ERROR: org.eclipse.pde.core code=0
> Problems loading repositories children=[Status ERROR: org.eclipse.pde.core
> code=0 Problems loading repositories children=[Status ERROR:
> org.eclipse.equinox.p2.metadata.repository code=1000 No repository found at
> file:///home/jenkins/agent/workspace/ep422I-unit-cen64-gtk3-java11/workarea/
> I20210927-1800/eclipse-testing/test-eclipse/eclipse/tests/sites/site.a.b.]]]
> 
> java.lang.AssertionError: Target resolution failed: Status ERROR:
> org.eclipse.pde.core code=0 Problems occurred while resolving the target
> contents children=[Status ERROR: org.eclipse.pde.core code=0 Problems
> loading repositories children=[Status ERROR: org.eclipse.pde.core code=0
> Problems loading repositories children=[Status ERROR:
> org.eclipse.equinox.p2.metadata.repository code=1000 No repository found at
> file:///home/jenkins/agent/workspace/ep422I-unit-cen64-gtk3-java11/workarea/
> I20210927-1800/eclipse-testing/test-eclipse/eclipse/tests/sites/site.a.b.]]]
> at
> org.eclipse.pde.core.tests.internal.DependencyManagerTest.
> createTPState(DependencyManagerTest.java:157)
> at
> org.eclipse.pde.core.tests.internal.DependencyManagerTest.
> testFindRequirementsClosure_RequireBundle2(DependencyManagerTest.java:59)

It looks like the URL is wrong:
file:///home/jenkins/agent/workspace/ep422I-unit-cen64-gtk3-java11/workarea/I20210927-1800/eclipse-testing/test-eclipse/eclipse/tests/sites/site.a.b

It should end with: org.eclipse.pde.ui.tests/tests/sites/site.a.b
My first suspicion is that the I builds use another working-directory than the PDE verification builds?
Comment 35 Eclipse Genie CLA 2021-09-28 03:47:03 EDT
New Gerrit change created: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/185885
Comment 36 Hannes Wellmann CLA 2021-09-30 15:13:29 EDT
(In reply to Vikas Chandra from comment #32)
> Hannes, can you please verify this fix in an I build

I have verified that this bug is fixed with version:
Version: 2021-12 (4.22)
Build id: I20210929-1800

I used the "Large mixed benchmark test case" attached to this bug by myself. With the mentioned version, when I press "Add Required Plug-ins" in the Run/Debug Configuration wizard all required plug-ins are added (except for the org.apache.xerces plug-ins, but it is not resolved in the TP, so I think is a bug there). A subsequent "Validate Plug-ins" confirms this.

Because of the mentioned test-failures in I-builds I keep this bug open until the change to fix the tests is submitted.
Comment 38 Andrey Loskutov CLA 2021-10-09 02:11:58 EDT
(In reply to Eclipse Genie from comment #37)
> Gerrit change https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/185885 was
> merged to [master].
> Commit:
> http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/
> ?id=d3af9f82cc9e15ddd4588a6c0eadae70e82c86a2

Thanks, that finally fixed the last failing test on Linux Java 11 build. I can't remember to see zero test failures on any of the builds we have for a long time. Hallelujah!
Comment 39 Hannes Wellmann CLA 2021-10-09 04:36:19 EDT
(In reply to Andrey Loskutov from comment #38)
> (In reply to Eclipse Genie from comment #37)
> > Gerrit change https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/185885 was
> > merged to [master].
> > Commit:
> > http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/
> > ?id=d3af9f82cc9e15ddd4588a6c0eadae70e82c86a2
> 
> Thanks, that finally fixed the last failing test on Linux Java 11 build. I
> can't remember to see zero test failures on any of the builds we have for a
> long time. Hallelujah!

That's great!

As I said in my comment 36 above, I verified the fix of this bug, so I'll change the state to verified fixed.