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

Bug 302487

Summary: WST server discovery service lookup problem
Product: [WebTools] WTP ServerTools Reporter: John Arthorne <john.arthorne>
Component: wst.serverAssignee: Angel Vera <arvera>
Status: CLOSED FIXED QA Contact: Angel Vera <arvera>
Severity: normal    
Priority: P3 CC: david_williams, deboer, thomas
Version: unspecifiedKeywords: plan
Target Milestone: 3.2 M7   
Hardware: PC   
OS: Windows XP   
See Also: https://git.eclipse.org/r/108868
Whiteboard:
Attachments:
Description Flags
Potential fix
none
Combined patch for two problems none

Description John Arthorne CLA 2010-02-10 14:40:16 EST
The code in bundle org.eclipse.wst.server.discovery tries to obtain p2 services using OSGi service lookups. As a result of changes in bug 299987 this will no longer succeed. P2 supports multiple agents in a given VM, so there is no longer a global notion of p2 services such as the planner, director, profile registry, etc. For further details see:

http://wiki.eclipse.org/Equinox/p2/Multiple_Agents
Comment 1 John Arthorne CLA 2010-02-10 14:42:24 EST
Created attachment 158765 [details]
Potential fix
Comment 2 John Arthorne CLA 2010-02-10 14:43:12 EST
Thomas can you take a quick look at the patch to double-check it?
Comment 3 John Arthorne CLA 2010-02-23 17:49:45 EST
I'm worried I reported this bug in the wrong place. To be clear this WST code will fail when running against platform build I20100216 or greater without this patch being released.
Comment 4 Angel Vera CLA 2010-02-23 18:01:16 EST
(In reply to comment #3)
John, this is the right place, I been busy with other stuff, and haven't had a chance to address this problem. I should be able to look at before WTP adopts that level of platform, which is hopefully not before the end of this week.
Comment 5 David Williams CLA 2010-02-24 23:51:50 EST
We will adopt a recent I build on Friday, and ... since Angle and I talked about it today via IM ... there will be a compile break, if not fixed before adoption It centers around _ IPlanner _ becoming API so old provisional API is gone. I think this issue is independent of what this bug is about ... but since all in same are of code, thought I'd document it here.
Comment 6 John Arthorne CLA 2010-02-25 08:50:17 EST
Created attachment 160182 [details]
Combined patch for two problems

In case it helps, here is a combined patch for both the planner change and the service lookup change. I have the WST plugin and all of p2 from HEAD in my workspace, and with this patch everything builds fine.
Comment 7 Angel Vera CLA 2010-02-26 14:38:15 EST
I have committed and released the code to HEAD. But during my testing I got a NPE that needs to be investigated. 

Exception in thread "Deferred Initialization" java.lang.NullPointerException
	at org.eclipse.wst.server.discovery.internal.ExtensionUtility.getExistingFeatures(ExtensionUtility.java:156)
	at org.eclipse.wst.server.discovery.internal.ExtensionUtility.getAllExtensions(ExtensionUtility.java:176)
	at org.eclipse.wst.server.discovery.internal.wizard.ExtensionComposite.deferredInitialize(ExtensionComposite.java:478)
	at org.eclipse.wst.server.discovery.internal.wizard.ExtensionComposite$7.run(ExtensionComposite.java:398)

The problem seems to be related to not being able to retrieve the profile, when we do:

IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF);
Comment 8 Angel Vera CLA 2010-03-03 17:47:38 EST
John, 

Iis there an equivalent call for: IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF) ? From the debugging so far it seems that there is no profiles in the registry.
Comment 9 John Arthorne CLA 2010-03-08 11:59:13 EST
(In reply to comment #8)
> Iis there an equivalent call for: IProfile profile =
> profileRegistry.getProfile(IProfileRegistry.SELF) ? From the debugging so far
> it seems that there is no profiles in the registry.

I assume you are debugging in a test workspace launched from Eclipse. Since the test instance hasn't been provisioned by p2 there is no profile for it. In the "Configuration" tab of your launch configuration, check off "Support software installation in the launched application". This will cause a profile to be spoofed up by PDE to match the target platform.
Comment 10 Angel Vera CLA 2010-03-11 14:07:54 EST
Even though the changes have been committed, there is still something we need look at because are not working. Even after I followed the suggestion of enabling "Support software installation in the launched application"

I moving this to M7 to continue the investigation.
Comment 11 Angel Vera CLA 2010-03-31 10:34:48 EDT
I am closing this bug as fixed as the changes that were proposed have been integrated. The work that is left is related to bug 305731
Comment 12 Eclipse Genie CLA 2017-10-11 16:31:10 EDT
New Gerrit change created: https://git.eclipse.org/r/108868