2012-03-07 24 views
3

ローカルのリポジトリからローカルで行うと、正常に動作し、再起動時に自動更新を行うことができますが、Webリポジトリから更新しようとすると、これらのエラーが発生します:P2 Webリポジトリからの自動更新

An internal error occurred during: "Install download0". 
org.eclipse.swt.SWTException: Invalid thread access 

本当に違いは何か分かりません。私ApplicationWindowWorkbenchAdvisorで 私はこのポストウィンドウopenメソッドがあります。

private static final String JUSTUPDATED = "justUpdated"; 

public void postWindowOpen() { 
    final IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper 
      .getService(Activator.bundleContext, 
        IProvisioningAgent.SERVICE_NAME); 
    if (agent == null) { 
     LogHelper 
       .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 
         "No provisioning agent found. This application is not set up for updates.")); 
    } 
    final IPreferenceStore prefStore = Activator.getDefault() 
      .getPreferenceStore(); 
    if (prefStore.getBoolean(JUSTUPDATED)) { 
     prefStore.setValue(JUSTUPDATED, false); 
     return; 
    } 

    IRunnableWithProgress runnable = new IRunnableWithProgress() { 
     public void run(IProgressMonitor monitor) 
       throws InvocationTargetException, InterruptedException { 
      IStatus updateStatus = P2Util.checkForUpdates(agent, monitor); 
      if (updateStatus.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) { 
       PlatformUI.getWorkbench().getDisplay() 
         .asyncExec(new Runnable() { 
          public void run() { 
           MessageDialog.openInformation(null, 
             "Updates", "No updates were found"); 
          } 
         }); 
      } else if (updateStatus.getSeverity() != IStatus.ERROR) { 
       prefStore.setValue(JUSTUPDATED, true); 
       PlatformUI.getWorkbench().restart(); 
      } else { 
       LogHelper.log(updateStatus); 
      } 
     } 
    }; 
    try { 
     new ProgressMonitorDialog(null).run(true, true, runnable); 
    } catch (InvocationTargetException e) { 
     e.printStackTrace(); 
    } catch (InterruptedException e) { 
    } 

} 

そして、私のP2Utilでこの:私のPreferenceInitializerで

public static IStatus checkForUpdates(IProvisioningAgent agent, 
     IProgressMonitor monitor) { 
    ProvisioningSession session = new ProvisioningSession(agent); 
    UpdateOperation operation = new UpdateOperation(session); 
    SubMonitor sub = SubMonitor.convert(monitor, 
      "Checking for application updates...", 200); 
    IStatus status = operation.resolveModal(sub.newChild(100)); 
    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) { 
     return status; 
    } 
    if (status.getSeverity() == IStatus.CANCEL) 
     throw new OperationCanceledException(); 

    if (status.getSeverity() != IStatus.ERROR) { 
     ProvisioningJob job = operation.getProvisioningJob(null); 
     status = job.runModal(sub.newChild(100)); 
     if (status.getSeverity() == IStatus.CANCEL) 
      throw new OperationCanceledException(); 
    } 
    return status; 
} 

この:

node.putBoolean(PreferenceConstants.PREF_AUTO_UPDATE_ENABLED, true); 
node.putBoolean(PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE, true); 
node.putBoolean(PreferenceConstants.PREF_DOWNLOAD_ONLY, true); 

を私は自分自身を繰り返します。ローカルからRepo私は自動更新を実行することはできますが、Web Repoでは実行できません。 読んでいただきありがとうございます。

答えて

4

問題のあるコードは、これはエラーをスローし、UIスレッドの外に呼び出され

new ProgressMonitorDialog(null).run(true, true, runnable); 

です...あなたはasyncExecコール

+0

でも、これをラップする必要があるはい、私は「という解決策ました"インターネット上では、常に私にそのエラーを与える。問題が新しいProgressMonitorだと言ったように。その代わりにNullProgressMonitorをすべて導入すると、すべて正常に動作します。\t IStatus updateStatus = P2Util.checkForUpdates(agent、new NullProgressMonitor());ありがとう:) –

関連する問題