Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3230970
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:59:24+00:00 2026-05-17T16:59:24+00:00

I have a personal Eclipse RCP product ( com.example.product ) based on one personal

  • 0

I have a personal Eclipse RCP product (com.example.product) based on one personal feature (com.example.feature) which is composed of one personal plugin (com.example.plugin) and a bunch of others from Eclipse Helios (3.6). I want the app to check for updates and update itself if necessary from a p2 site. I want it to be headless, ie the user does not interact in the update process, but may see progress in a dialog.

I based my implementation for the updates on the RCP Mail application. I changed the P2Util.checkForUpdates method a bit to include some logging so I can see what, if anything, is going wrong there:

    static IStatus checkForUpdates(IProvisioningAgent agent,
        IProgressMonitor monitor) throws OperationCanceledException,
        InvocationTargetException {
    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) {
        try {
            logger.info( "Status is " + status );
            Update[] updates = operation.getPossibleUpdates();              
            for( Update u : updates){
                logger.info( "Update is " + u );
            }               
            ProvisioningJob job = operation.getProvisioningJob(null);
            if( job == null ){
                logger.error( "Provisioning Job is null" );
            }
            status = job.runModal(sub.newChild(100));
            if (status.getSeverity() == IStatus.CANCEL) {
                throw new OperationCanceledException();
            }
        } catch ( Exception e ){
            logger.error( "Exception while trying to get updates", e);
        }
    }
    return status;
}

I have a p2.inf file in my feature at the same level as my example.product file. It contains:

org.eclipse.equinox.p2.touchpoint.eclipse.addRepository": 
instructions.configure=\ 
org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(type:0,location:file${#58}/C${#58}/workspace/updatesite/);\
org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(type:1,location:file${#58}/C${#58}/workspace/updatesite/);

I build the product with plugin, feature and product IDs set to 1.0.0.
I can export and run my product from eclipse using the product export wizard. I tick generate metadata repository when I do this.

I create my update site using the Create an Update Site Project option in the Feature Manfiest Editor. I add my `com.example.feature’ and build it. Just to see if it works I try browsing it via eclipse IDE Install New Software option and I can see the feature there.

I build the update site with all 3 IDs changed to 1.0.1. When I start the app it says there are no updates to install, there are no errors in the logs.

I don’t know why it doesn’t update from the update site, but things that have crossed my mind are:

1) I may need more info in the p2.inf file, but I’m not sure what, maybe something like namespace, name and range, but I can’t find a good practical example.

2) In the checkForUpdates method I may need to do something with profiles to change what installable units are being updated. Again, I only found comments hinting at this and not any example code that shows how.

Any hints or ideas are much appreciated here, this is eating a lot of time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:59:24+00:00Added an answer on May 17, 2026 at 4:59 pm

    @user473284’s answer had some suggestions that I used but I don’t know if they were definite requirements

    1) using a local web server instead of trying to point to a file
    2) Incrementing the product version and using the update repository generated by the export product wizard.

    I never did find the implementation for the getUpdate method referenced from the code sample so I couldn’t make use of the snippet.

    After the above changes I was still left with the app detecting no updates on startup. Debugging showed that my repository was not showing up in the session. I had to explicitly add the update url in the code, despite having it in the p2.inf and in set in the feature manifest editor form field. Here’s the code for this:

        public static void addUpdateSite(IProvisioningAgent provisioningAgent)
            throws InvocationTargetException {
        // Load repository manager
        IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) provisioningAgent
                .getService(IMetadataRepositoryManager.SERVICE_NAME);
        if (metadataManager == null) {
            logger.error( "Metadata manager was null");
             Throwable throwable = new
             Throwable("Could not load Metadata Repository Manager");
             throwable.fillInStackTrace();
             throw new InvocationTargetException(throwable);
        }
    
        // Load artifact manager
        IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) provisioningAgent
                .getService(IArtifactRepositoryManager.SERVICE_NAME);
        if (artifactManager == null) {
            logger.error( "Artifact manager was null");
            Throwable throwable = new Throwable(
                    "Could not load Artifact Repository Manager");
            throwable.fillInStackTrace();
            throw new InvocationTargetException(throwable);
        }
    
        // Load repo
        try {
            URI repoLocation = new URI("http://localhost/respository");
            logger.info( "Adding repository " + repoLocation );
            metadataManager.loadRepository(repoLocation, null);
            artifactManager.loadRepository(repoLocation, null);
        } catch (ProvisionException pe) {
            logger.error( "Caught provisioning exception " + pe.getMessage(), pe);
            throw new InvocationTargetException(pe);
        } catch (URISyntaxException e) {
            logger.error( "Caught URI syntax exception " + e.getMessage(), e);
            throw new InvocationTargetException(e);
        }
    }
    

    I now call this first thing in the checkForUpdates method from the original question. After this change my app at least now sees the update and attempts to install it. I’m still having problem but that deserves a separate question of its own which I’ve created at https://stackoverflow.com/questions/3944953/error-during-p2-eclipse-rcp-app-headless-update

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.