Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » P2 » URI is not hierarchical
URI is not hierarchical [message #1014819] Tue, 26 February 2013 14:25
Bastian Wagenfeld is currently offline Bastian WagenfeldFriend
Messages: 183
Registered: January 2013
Senior Member
Hi,

I am creating an Eclipse 4 RCP that should update itself via P2. Therefore I implemented the (basically) following code:
		ServiceReference<?> reference = Activator.context
				.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME);
		IProvisioningAgentProvider provider = null;
		if (reference == null)
			return null;
		provider = (IProvisioningAgentProvider) Activator.context
				.getService(reference);
		Bundle bundle = FrameworkUtil.getBundle(Service.class);
		URL url = FileLocator.toFileURL(FileLocator.find(bundle,
				new Path("p2"), null));
                IProvisioningAgent agent = provider.createAgent(new URI("file:"
				+ url.getPath().substring(1)));

                IMetadataRepositoryManager metadataManager =(IMetadataRepositoryManager) agent
				.getService(IMetadataRepositoryManager.SERVICE_NAME);
		IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent
				.getService(IArtifactRepositoryManager.SERVICE_NAME);
		if (artifactManager == null || metadataManager == null)
			throw new InvocationTargetException(new Throwable(
					"Could not load repository").fillInStackTrace());

		URI repositoryLocation = new URI(Service.getString("updateSite"));

		metadataManager.loadRepository(repositoryLocation, null);
		artifactManager.loadRepository(repositoryLocation, null);

                ProvisioningSession session = new ProvisioningSession(agent);
		UpdateOperation operation = new UpdateOperation(session);

		SubMonitor sub = SubMonitor.convert(new Monitor(),
					"Updating...", 500);
		IStatus status = operation.resolveModal(sub.newChild(100));
		


The last line throws the following exception:
Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
	at java.io.File.<init>(File.java:392)
	at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.getDefaultRegistryDirectory(SimpleProfileRegistry.java:109)
	at org.eclipse.equinox.internal.p2.engine.ProfileRegistryComponent.createService(ProfileRegistryComponent.java:26)
	at org.eclipse.equinox.internal.p2.core.ProvisioningAgent.getService(ProvisioningAgent.java:72)
	at org.eclipse.equinox.p2.operations.ProvisioningSession.getProfileRegistry(ProvisioningSession.java:88)
	at org.eclipse.equinox.p2.operations.UpdateOperation.getInstalledIUs(UpdateOperation.java:295)
	at org.eclipse.equinox.p2.operations.UpdateOperation.prepareToResolve(UpdateOperation.java:280)
	at org.eclipse.equinox.p2.operations.ProfileChangeOperation.resolveModal(ProfileChangeOperation.java:112)
	at de.test.e4.editor.handler.UpdateHandler.update(UpdateHandler.java:58)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	... 30 more

The URI for the Agent looks like this:
file:D:/workspace/de.test.e4.editor/p2/

The URI for the repositories looks like this:
http://localhost:8080/server/repository

It doesn't make a difference, if the repository is a local file.
Did anybody else experience something like this?

I would be happy for any hint.

Best regards
Bastian
Previous Topic:sites to use during a feature installation
Next Topic:Errors related to Generics while compiling OSGi-Equinox dependent code with JDK 1.7
Goto Forum:
  


Current Time: Tue Mar 19 02:05:45 GMT 2024

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

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

Back to the top