Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 311795

Summary: P2 provisioning of a target platform does not take into account the execution profile
Product: [Eclipse Project] PDE Reporter: Hugues Malphettes <hmalphettes>
Component: UIAssignee: PDE-UI-Inbox <pde-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: major    
Priority: P3 CC: david_williams, gunnar, hmalphettes, holger.herzog, jeffmcaffer
Version: 3.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Bug Depends on:    
Bug Blocks: 307571    
Attachments:
Description Flags
p2repository for a single feature that contains a single jar: javax.activation none

Description Hugues Malphettes CLA 2010-05-05 16:47:51 EDT
Created attachment 167231 [details]
p2repository for a single feature that contains a single jar: javax.activation

When creating a new target platform and trying to provision it with bundles that import packages provided by J2SE-1.5, the P2 resolver complains that it cannot find a bundle that provide that package.

Here is a first example: https://bugs.eclipse.org/bugs/attachment.cgi?id=167071

Attached is the smallest testcase: a p2-repository with a single feature and a single plugin in that feature: javax.activation as packaged by eclipse orbit.

To reproduce the issue: Unzip that p2repo somewhere on the file system.
Create a new blank Target Platform with PDE (3.6M6 or 3.6M7) and try to provision it with an update site that points to the local folder where this repository is unzipped.


I have tried defining the the target platform's execution environment via the JRE radio button and via the execution environment drop-down.
I have also assigned to J2SE-1.5 Execution Environment the proper JDK.
It does not seem to make a difference.

The workaround consists of unchecking the option "Include Required Dependencies" when provisioning the target platform.

Let me know if I am missed something.
Thanks,
Hugues.
Comment 1 Hugues Malphettes CLA 2010-05-06 12:52:29 EDT
After further research I stumbled upon:
http://dev.eclipse.org/mhonarc/lists/p2-dev/msg02500.html

I'll try to find out what type of IUs the jetty site need to generate.
Comment 2 Gunnar Wagenknecht CLA 2010-05-13 01:53:31 EDT
You can try running a product build. :) I'm not sure, but I also heard that sometimes people depend on "system.bundle" explicitly. But I'm not sure if it was in that context.
Comment 3 Hugues Malphettes CLA 2010-05-13 12:06:47 EDT
Thanks Gunnar for looking at it.

I think there are 2 ways to tackle this:
1- on the p2-repository generated from an update site with the http://wiki.eclipse.org/Equinox/p2/Publisher#UpdateSite_Publisher_Application

So far the best explanation I have found is: http://www.eclipse.org/forums/index.php?t=msg&goto=502560

We are using tycho to generate our site and I am diving into the publisher part of it so maybe I'll stumble onto a way to do this.


2- On the PDE side: insert the <unit id='a.jre.javase' version='1.6.0' singleton='false'> (for example)
according to the tab.


At least that is my understanding.

Of course on this bug filed against PDE we are focusing on the approach #2.
It would be great if someone could review this and let us know if that is a good idea I would be quite grateful.

For approach #1 I have not found out the reason why the UpdateSite Publisher Application does not generate the JRE IU.
Comment 4 Hugues Malphettes CLA 2010-05-13 19:12:05 EDT
(In reply to comment #2)
> You can try running a product build. :)
Yes when I build a product and use it as a site then I can see the extra IU for javase and I can install it without problems.
So when running FeaturesAndBundlesPublisher followed by ProductPublisher we do get that.

> I'm not sure, but I also heard that
> sometimes people depend on "system.bundle" explicitly. But I'm not sure if it
> was in that context.

I tried that just to make sure and that does not insert an extra IU for javase into the content.xml generated by P2 via the UpdateSite Publisher 

I have read that the update site publisher was meant to generate "incomplete repositories that can be used in combination with other IUs".
This would push towards supporting this enhancement in PDE itself.
Comment 5 Holger Herzog CLA 2010-12-02 03:36:47 EST
Thank you for your good analysis and description, Hugues. I also succeeded in using the "FeaturesAndBundlesPublisher"-Patch, but I needed feature categories, and therefore I started to patch the "UpdateSitePublisher". And when I opened the source code, I recognized that there is an (undocumented?? switch already, called "-addJREIU".

So for everyone gooogleing and ending up here, here's a solution using that switch:

1.) Create features and plugins in the folder where you're side.xml resides just as usual (e.g. by using site.xml --> Build All). The created content.jar does not contain the JRE-IU.

2.) Run the Update-Site-Publisher with that site as source and add the parameter "-addJREIU":

java -jar PATH_TO_ECLIPSE_361/plugins/org.eclipse.equinox.launcher_*.jar -addJREIU -application org.eclipse.equinox.p2.publisher.UpdateSitePublisher -metadataRepository file://TARGET_PATH -artifactRepository file://TARGET_PATH -source PATH_TO_SOURCE_SITE -compress -publishArtifacts

In the target path you'll find the new content.jar, including the JRE-IU.

Sorry for posting that solution here, but it was hardly to find out for me and this big is open and nearly untouched since more than 6 month.
Comment 6 Holger Herzog CLA 2010-12-02 03:45:27 EST
Readers please note: This bug is related to bug #313454.
Comment 7 Jeff McAffer CLA 2010-12-02 10:12:29 EST
p2 has the notion of a JRE IU that describes the packages made available by the JRE.  This is roughly equivalent to the content of the .profile files in the org.eclipse.osgi bundle.  This is needed because some bundles import javax.* etc packages that ultimately come from the JRE.  At runtime these are "supplied" by the framework but in p2 land we need an IU that says it supplies them.

For any given provisioning operation at least one of the metadata repos involved needs provide the things that are being "required".  Mostly that is a matter of publishing the bundles and features involved.  For the JRE IU we supplied an (apparently undocumented) option -addJREIU that Holger points out (thanks).  This will cause the JRE IU to be published into the destination repo.  An alternative approach is to ensure that the provisioning operation has access to a repo that already has the JRE IU.  For example, the Helios repo.  Of course, that is not always convenient but it is key to understanding what's going on here.

Sidenote: for category publishing there is a CategoryPublisherApplication you can use to add categories into a repo.  Note also that categories do not need to be in the same repo as the things they categorize.  When p2 runs it mashes together all the repo so the actual physical origins don't matter.
Comment 8 Eclipse Webmaster CLA 2019-09-06 16:17:03 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 9 Julian Honnen CLA 2019-09-09 02:43:17 EDT
Please remove the stalebug flag, if this issue is still relevant and can be reproduced on the latest release.