Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Building custom installer with p2
Building custom installer with p2 [message #555700] Fri, 27 August 2010 17:24 Go to next message
Mitch McCuiston is currently offline Mitch McCuistonFriend
Messages: 2
Registered: August 2010
Junior Member
I am trying to build an application installer that launches a p2 UI and allows the user to browse a catalog of features to install. I am new to eclipse rcp development and I'm having some trouble getting started. I have been able to launch a DiscoveryWizard but a nullpointerexception is thrown behind the scenes.

Caused by: java.lang.NullPointerException
at org.eclipse.equinox.internal.p2.ui.discovery.wizards.Catalog Viewer.getInstalledFeatures(CatalogViewer.java:448)
at org.eclipse.equinox.internal.p2.ui.discovery.wizards.Catalog Viewer$6.run(CatalogViewer.java:566)
at org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:121)


From the looks of the NPE it appears that p2 relies on some back end services to be initalized and registered with the provisioning agent (i.e. instance of IPluginRegistry).
The snippet below is the line that is returning a null service that the p2 UI apparently expects to be there.

//org.eclipse.equinox.internal.p2.ui.ProvUI.java
/**
* Return the profile registry for the given session
* @return the profile registry
*/
public static IProfileRegistry getProfileRegistry(ProvisioningSession session) {
return (IProfileRegistry) session.getProvisioningAgent().getService(IProfileRegistry.S ERVICE_NAME);
}



I'm not really sure where this initialization step is supposed to happen. I would be extremely grateful if anyone out there can give me some tips or point me in the right direction.
Re: Building custom installer with p2 [message #658013 is a reply to message #555700] Sat, 05 March 2011 00:35 Go to previous message
Philip Borlin is currently offline Philip BorlinFriend
Messages: 30
Registered: July 2009
Member
Try the following code. I put this in my Activator and it started working. DS is needed to make sure service activation is done. The engine actually contains the implementation of IProfileRegistry. I am not sure if the middle two are needed but updating started working and I didn't want to touch anything.

@Override
public void start(BundleContext context) throws Exception {
    ServiceReference packageAdminRef = context.getServiceReference(PackageAdmin.class.getName());
    PackageAdmin packageAdmin = (PackageAdmin)context.getService(packageAdminRef);

    getBundle("org.eclipse.equinox.ds", packageAdmin); //$NON-NLS-1$
    getBundle("org.eclipse.equinox.frameworkadmin.equinox", packageAdmin); //$NON-NLS-1$
    getBundle("org.eclipse.equinox.simpleconfigurator.manipulator", packageAdmin); //$NON-NLS-1$
    getBundle("org.eclipse.equinox.p2.engine", packageAdmin); //$NON-NLS-1$
}

private static void getBundle(String symbolicName, PackageAdmin packageAdmin)
          throws BundleException {
    if (packageAdmin != null) {
      Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
      if (bundles != null) {
        for (int i = 0; i < bundles.length; i++) {
          if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
            bundles[i].start(Bundle.START_TRANSIENT);
          }
        }
      }
    }
}


-Phil
Previous Topic:Headless self-update issue
Next Topic:Who decides what launchers that are available?
Goto Forum:
  


Current Time: Tue Apr 23 12:52:37 GMT 2024

Powered by FUDForum. Page generated in 0.03193 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top