P2 check for updates doesn't work [message #1711851] |
Tue, 20 October 2015 03:18  |
Eclipse User |
|
|
|
Hi,
I'm trying to update my application using P2 following this online tutorial.
I have a p2 repository hosted on a local Apache server and my application doesn't seems to detect updates on it. There is also no P2 request logged in the access.log of the Apache server.
So I have two problems :
- When my p2 repo does not exist, update service doesn't throw an error or a warning.
- When my p2 repo is up and contains update, the update service tells me that there is no available update.
Do you have any advice to debug it simply ? or help me with some example code?
Here the code of my update handler :
public class UpdateHandler {
/** The Logger */
private static final Logger LOG = Logger.getLogger(UpdateHandler.class);
/** The Repository URL */
private static final String REPOSITORY_LOC = "http://localhost/repository";
@Inject
UISynchronize sync;
@Execute
public void execute(IProvisioningAgent agent, UpdateService updateService, IWorkbench workbench) {
LOG.debug("execute: " + this.getClass().getName());
LOG.debug("Adding P2 repository : " + REPOSITORY_LOC);
P2Util.addRepository(agent, REPOSITORY_LOC);
final CancelableOperation<Optional<UpdatePlan>> check = updateService.checkUpdate(ProgressReporter.NULLPROGRESS_REPORTER);
check.onCancel(() -> showInformation("Operation cancelled"));
check.onException(t -> showError(t.getStatus().getMessage()));
check.onComplete(updatePlan -> {
if (!updatePlan.isPresent()) {
showInformation("Nothing to update");
}
else {
if (showConfirmation("Updates available", "There are updates available. Do you want to install them now?")) {
final CancelableOperation<UpdateResult> result = updatePlan.get().runUpdate(ProgressReporter.NULLPROGRESS_REPORTER);
result.onCancel(() -> showInformation("Operation cancelled"));
result.onException(t -> showError(t.getLocalizedMessage()));
result.onComplete(r -> {
if (showConfirmation("Updates installed, restart?", "Updates have been installed successfully, do you want to restart?")) {
sync.syncExec(() -> workbench.restart());
}
});
}
}
});
}
}
And my P2Util used to add the repository location :
public class P2Util {
/** The Logger */
private static final Logger LOG = Logger.getLogger(P2Util.class);
public static boolean addRepository(IProvisioningAgent agent, String repo) {
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (metadataManager == null) {
LOG.error("metadataManager is null!!!");
return false;
}
if (artifactManager == null) {
LOG.error("artifactManager is null!!!");
return false;
}
try {
URI uri = new URI(repo);
metadataManager.addRepository(uri);
artifactManager.addRepository(uri);
return true;
} catch (Exception e) {
return false;
}
}
}
|
|
|
|
|
|
|
|
|
|
|
|
Re: P2 check for updates doesn't work [message #1711991 is a reply to message #1711988] |
Tue, 20 October 2015 11:22   |
Eclipse User |
|
|
|
We are simply repackaging the ecf-Feature they provide and it looks like
they don't bring "org.eclipse.core.net" with them.
I've update our target to ship core.net now as well and started a new
build. You should try adding core.net to your feature and check if
things now work with an exception?
Tom
On 20.10.15 17:08, Tom Schindl wrote:
> so there's a missing dependency?
>
> Tom
>
> On 20.10.15 16:57, Thibault Pensec wrote:
>> Quote:
>>> Are you sure that your P2Util is working as intended? Have you tried
>>> using a p2.inf?
>>
>> Yes, I've tried ;) But I really need to change P2 repository location at
>> runtime.
>> Quote:
>>> Did you try to connect to your local update site via the Eclipse
>>> Installation Manager?
>>
>> Yes, it works perfectly.
>> I added some code in P2Util to check the repo when adding it to the
>> IProvisioningAgent :
>> public class P2Util {
>>
>> /** The Logger */
>> private static final Logger LOG = Logger.getLogger(P2Util.class);
>>
>> /**
>> * Add a repository to declared updates repositories.
>> * @return
>> */
>> public static boolean addRepository(IProvisioningAgent agent, URI
>> uri) {
>> boolean added = true;
>>
>> IMetadataRepositoryManager metadataManager =
>> (IMetadataRepositoryManager)
>> agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
>> IArtifactRepositoryManager artifactManager =
>> (IArtifactRepositoryManager)
>> agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
>>
>> if (metadataManager == null) {
>> LOG.error("metadataManager is null!!!");
>> return false;
>> }
>> if (artifactManager == null) {
>> LOG.error("artifactManager is null!!!");
>> return false;
>> }
>>
>> try {
>>
>> metadataManager.addRepository(uri);
>> metadataManager.loadRepository(uri, new
>> NullProgressMonitor()); // HERE
>>
>> artifactManager.addRepository(uri);
>> artifactManager.loadRepository(uri, new
>> NullProgressMonitor()); // AND HERE
>>
>> } catch (Exception e) {
>> LOG.error("An error occurred while adding repository from
>> URI['" + uri + "']. Cause : ", e);
>> added = false;
>> }
>>
>> return added;
>> }
>> }
>>
>>
>> Du to this code, the following error is thrown :
>> !ENTRY org.eclipse.ecf.provider.filetransfer.httpclient4 4 0 2015-10-20
>> 16:46:33.222
>> !MESSAGE
>> org.eclipse.core.runtime.Status[plugin=org.eclipse.ecf.provider.filetransfer.httpclient4;code=4;message=Warning:
>> Platform proxy API not
>> available;severity2;exception=java.lang.NoClassDefFoundError:
>> org/eclipse/core/net/proxy/IProxyService;children=[]]
>> !STACK 0
>> java.lang.NoClassDefFoundError: org/eclipse/core/net/proxy/IProxyService
>> at
>> org.eclipse.ecf.provider.filetransfer.httpclient4.HttpClientRetrieveFileTransfer.setupProxies(HttpClientRetrieveFileTransfer.java:316)
>>
>> at
>> org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.sendRetrieveRequest(AbstractRetrieveFileTransfer.java:884)
>>
>> at
>> org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.sendRetrieveRequest(AbstractRetrieveFileTransfer.java:576)
>>
>> at
>> org.eclipse.ecf.provider.filetransfer.retrieve.MultiProtocolRetrieveAdapter.sendRetrieveRequest(MultiProtocolRetrieveAdapter.java:106)
>>
>> at
>> org.eclipse.equinox.internal.p2.transport.ecf.FileReader.sendRetrieveRequest(FileReader.java:426)
>>
>> at
>> org.eclipse.equinox.internal.p2.transport.ecf.FileReader.readInto(FileReader.java:358)
>>
>> at
>> org.eclipse.equinox.internal.p2.transport.ecf.RepositoryTransport.download(RepositoryTransport.java:101)
>>
>> at
>> org.eclipse.equinox.internal.p2.transport.ecf.RepositoryTransport.download(RepositoryTransport.java:156)
>>
>> at
>> org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadIndexFile(AbstractRepositoryManager.java:735)
>>
>> at
>> org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:657)
>>
>> at
>> org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
>>
>> at
>> org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:92)
>>
>> at dp.fast.app.update.util.P2Util.addRepository(P2Util.java:45)
>> at
>> dp.fast.app.update.handler.UpdateHandler.execute(UpdateHandler.java:49)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>
>> at java.lang.reflect.Method.invoke(Method.java:497)
>> at
>> org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252)
>>
>> at
>> org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234)
>> at
>> org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
>>
>> at
>> org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
>>
>> at
>> org.eclipse.core.commands.Command.executeWithChecks(Command.java:493)
>> at
>> org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486)
>>
>> at
>> org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
>>
>> at
>> org.eclipse.fx.ui.workbench.renderers.base.BaseItemRenderer.executeAction(BaseItemRenderer.java:210)
>>
>> at
>> org.eclipse.fx.ui.workbench.renderers.base.BaseMenuItemRenderer$1.run(BaseMenuItemRenderer.java:50)
>>
>> at
>> org.eclipse.fx.ui.workbench.renderers.fx.DefMenuItemRenderer$MenuItemImpl$2.handle(DefMenuItemRenderer.java:137)
>>
>> at
>> org.eclipse.fx.ui.workbench.renderers.fx.DefMenuItemRenderer$MenuItemImpl$2.handle(DefMenuItemRenderer.java:1)
>>
>> at
>> com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
>>
>> at
>> com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
>>
>> at
>> com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
>>
>> at
>> com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
>>
>> at
>> com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
>>
>> at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
>> at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
>> at javafx.event.Event.fireEvent(Event.java:198)
>> at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
>> at
>> com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1405)
>>
>> at
>> com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$343(ContextMenuContent.java:1358)
>>
>> at
>> com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
>>
>> at
>> com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
>>
>> at
>> com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
>>
>> at
>> com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
>>
>> at
>> com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
>>
>> at
>> com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
>>
>> at
>> com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
>>
>> at
>> com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
>>
>> at
>> com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
>>
>> at
>> com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
>>
>> at
>> com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
>>
>> at
>> com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
>>
>> at
>> com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
>>
>> at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
>> at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
>> at javafx.event.Event.fireEvent(Event.java:198)
>> at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
>> at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
>> at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
>> at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
>> at
>> com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:352)
>>
>> at
>> com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275)
>>
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>> com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$355(GlassViewEventHandler.java:388)
>>
>> at
>> com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
>>
>> at
>> com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:387)
>>
>> at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
>> at com.sun.glass.ui.View.notifyMouse(View.java:937)
>> at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
>> at
>> com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191)
>>
>> at java.lang.Thread.run(Thread.java:745)
>> Caused by: java.lang.ClassNotFoundException:
>> org.eclipse.core.net.proxy.IProxyService cannot be found by
>> org.eclipse.ecf.provider.filetransfer_3.2.200.v20150810-1719
>> at
>> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
>>
>> at
>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
>>
>> at
>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
>>
>> at
>> org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
>>
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>> ... 72 more
>>
>>
>>
>
|
|
|
|
|
|
|
|
|
|
Re: P2 check for updates doesn't work [message #1712024 is a reply to message #1712016] |
Tue, 20 October 2015 15:28  |
Eclipse User |
|
|
|
According to https://wiki.eclipse.org/Tycho/eclipse-repository should do
the trick but when doing the export with PDE inside Eclipse this does
not work, need to test this with a tycho build.
Tom
On 20.10.15 20:11, Tom Schindl wrote:
> I've now added the equinox.security and core.net to the p2-feature so if
> you update the target you should get core.net deployed.
>
> Tom
>
> On 20.10.15 20:01, Tom Schindl wrote:
>> It depends what the update does and what you want to happen there's the
>> RestartService who allows to clear the persisted state on restart.
>>
>> Tom
>>
>> On 20.10.15 19:35, Thibault Pensec wrote:
>>> A last thing :) To make the update visible, I need to manually delete
>>> the workspace/ folder at the root of my exported product... And calling
>>> the workbench.restart() method simply close the application but don't
>>> restart it.
>>> Do I have to do something else before restarting the application ? Like
>>> removing workspace/ folder manually ?
>>
>
|
|
|
Powered by
FUDForum. Page generated in 0.06941 seconds