Hi
Thomas,
The
NullPointer is in
IProfile profile = "">session.getProfileRegistry().getProfile(profileId),
So either the profile or the profile registry could be null.
Check whether your profile is not null. This is unlikely.
The profile registry could be null if the IprofileRegistry service is not
registered.
IProfileRegistry getProfileRegistry() {
return
(IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
IprofileRegistry
is provided
by org.eclipse.equinox.p2.engine as a Declarative service.
So
the IprofileRegistry service is not
registered at the time of the NullPointer:
This
could happen if:
1.
The org.eclipse.equinox.p2.engine is not
started at that time of the NullPointer: check whether it is started and ensure
it starts before your bundle.
2.
org.eclipse.equinox.p2.engine is started,
but the DS still is unregisterd (as the register happens asynchronous)
What you can do is to force the registering of the service.
In your code before
UpdateOperation operation = new UpdateOperation(session);
Try to get the IProfileRegistry
service
Context is the Bundle context:
ServiceReference[] references = context.getAllServiceReferences(IprofileRegistry.class.getName(),
null);
This will give you an array of ServiceReferences.
ServiceReference reference = // get one of the services
you choose from references(it will be probably just one)
// this will enforce the registering of the service
Context.getService(reference);
Regards,
Elena
From: p2-dev-bounces@xxxxxxxxxxx
[mailto:p2-dev-bounces@xxxxxxxxxxx] On Behalf Of Thomas Kratz
Sent: Friday, May 14, 2010 6:33 PM
To: p2-dev@xxxxxxxxxxx
Subject: [p2-dev] Follow-Up: trouble with prestartupdate example
Hi all,
some digging made me add a try catch in the workbench
startup.
!SESSION
2010-05-14 17:29:37.989 -----------------------------------------------
java.vendor=Sun
Microsystems Inc.
BootLoader
constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE
Command-line
arguments: -os win32 -ws win32 -arch x86_64
!ENTRY
org.eclipse.equinox.p2.examples.rcp.prestartupdate 1 0 2010-05-14 17:29:41.616
!MESSAGE
Checking for updates
!ENTRY
org.eclipse.equinox.p2.examples.rcp.prestartupdate 4 0 2010-05-14 17:29:41.633
java.lang.NullPointerException
at
org.eclipse.equinox.p2.operations.UpdateOperation.getInstalledIUs(UpdateOperation.java:296)
at org.eclipse.equinox.p2.operations.UpdateOperation.prepareToResolve(UpdateOperation.java:281)
at
org.eclipse.equinox.p2.operations.ProfileChangeOperation.resolveModal(ProfileChangeOperation.java:112)
at
org.eclipse.equinox.p2.examples.rcp.prestartupdate.P2Util.checkForUpdates(Unknown
Source)
at
org.eclipse.equinox.p2.examples.rcp.prestartupdate.ApplicationWorkbenchAdvisor$1.run(Unknown
Source)
I guess I
need some more p2 bundles to be started when I have no UI to get the
Provisioning Service.
But I have no
clue what to start, as the example in the wiki uses examplarysetup which tells
it obsolete and does not work either.
Is there any
documentation in this ?