A very common use case in a domain specific RCP app is to update itself using p2. When deploying this app, it would be very convenient if a list of predefined update sites could be available for the application at the first start. This was possible (but not trivial) even with Eclipse 3.4. But now, with Eclipse 3.5.1, it is very easy to do:
- Put your product configuration file in a bundle (plug-in project), not in a feature
- Create a file at top level and name it p2.inf
- Put the following content in the file:
addRepository(type:0,location:YOUR METADATA REPOSITORY);
addRepository(type:1,location:YOUR ARTIFACT REPOSITORY);
- Don’t forget to include p2.inf in the build.properties
You find a working example in my MP3 Manager demo application:
If you want to test is with file locations rather than Internet locations, you could use locations like
The above location works for Windows, mind that in the file case there is only one / after the colon.
A list of all available p2 touchpoint instructions you find in the Eclipse Wiki.
This Post Has 22 Comments
Really cool tip. Thanks Kai
Do you have any idea why these repositories aren’t listed when the p2 directory is write protected, e.g., when you install your app into c:program files on Windows Vista or Windows 7 (these directories are write protected by default). As far as i have seen, this problem also happens with the MP3 Manager. It only works when the MP3 Manager is installed directly from the NSIS installer as the NSIS installer seems to grab the necessary priviliges to write to the p2 directory. My attempts to redirect configuration directories somewhere to user.home all failed unfortunately.
Sorry @Ben, I have no idea. If I find the time I’ll check it out in Vista.
I’ve see the behavior you’re referring to. The problem is that the “configuration” directory can’t be modified if the user running Eclipse does not have permissions. The pre-populated update sites (in the form of touchpoint actions) cause files to get written out to that location the first time you launch Eclipse. This was also the case in 3.4, if you used the *.prefs workaround (like how Ganymede did it) to set up a pre-installed update site.
I believe you can specify the -configuration area to a location that is writable (for example, the user home location). Alternatively, you can run Eclipse as an administrator.
I believe i have tried redirecting the configuration directory to user.home as i have written already. i believe it was the p2 directory that needed write permissions and that one is separate and parallel to the configuration directory. I could redirect the p2 directory somewhere to user.home as well, but then it only works if i copy the p2 directory from the program directory to the p2 directory in user.home beforehand, otherwise some data seems to be missing. With some ugly installer hacks, this may be possible to achieve, but i was somehow hoping that someone dealt with this problem already and knows a better answer.
Sigh, should have read your post more carefully. Sorry!
I’m more or less in the same boat as you. In general, my clients have typically just run the app as an admin to get around these issues… but that’s sort of a sledgehammer approach.
In hopes of getting some feedback from the RT guys, I’ve started a thread on this topic in the Equinox forum: http://www.eclipse.org/forums/index.php?t=msg&th=158858&start=0&S=f891290a9cb140d2677d56dabca3432f
I’d be surprised if anyone answers. I have mentioned this issue multiple times in the newsgroups and wrote a lengthy comment somewhere in the Bugzilla. I never got any reaction from anyone. I’m kind of happy that at least someone confirmed the problem, because i was seriously starting to believe that no one else has the issue.
@Ben & @(Other Ben)
One reason that not many people are picking up on this might be that some big companies still run XP internally. I guess if they start adopting Windows 7 these issues will get more interest.
Wow, there is a reply in the newsgroups:
I have to process this information a little more. I have a hunch that the problems are in fact caused by the fact that the software is actually run directly from the installer for the first time with admin priviliges (because the installer passes the privileges to the app). The configuration then somehow gets written to the virtualstore for program files and everything is messed up. Something like that maybe.
But why I have to put the product file in a bundle and not in a feature? Can you give me a little more background about this one?
Actually when you use p2 together with an RCP product, the p2.inf should be in the bundle that has the product definition in its plugin.xml. The actual product configuration probably could still remain in the feature since this file is not needed during deployment. I will check that out if I find the time.
I tried it and it works even with features. But I have to use the fully qualified name for the Touchpoint action: org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(…
Pingback: PDE Headless Build and P2 « Manuel Selva’s Eclipse blog
hi, boys. i am test p2.inf, is very interesting but it’s possible create repository in https??
thanks for all. Very interesting web
I’m getting Nullpointer exception at RepositoryTransport.download(RepositoryTransport.java:75) if I point to a remote repository. It works fine with local repository in the build directory. I have created the following bug – https://bugs.eclipse.org/bugs/show_bug.cgi?id=323149. Please let me know if anyone has a solution for this.
Any help on the previous issue?
Can we change the addRepository location path after we export our application
So we don’t have to edit the p2.inf and create a new product export
Is there anyway we can change it?
I am working on Eclipse RCP application and using p2 to update the feature.
I am facing one problem while updating the feature installed in RCP. I will explain this in two scenarios
The feature is already included in the exported RCP Product. I am using p2.inf to include following information
requires.1.namespace = org.eclipse.equinox.p2.iu
requires.1.name = com.example.mail.core.feature.group
requires.1.range = [1.0.0,2.0.0)
Once the product is exported, it launches successfully. Later I update the feature and increment the version to 1.0.1 and publish it to web server.
After that I added the update site url in the Eclipse RCP using Help > Install new software feature and I could see that it detects the updates and installs it successfully.
Now I change the p2.inf to pre-configure the update url and added following lines
Reset all the versions to 1.0.0 and export the product again.
After executing the exported product, I found that the update url is already configured in update manager.
I exported the feature as 1.0.1 and selected “Check for updates” option. As expected it detected the update and asked to install it. When I clicked finish button, I got following error.
!ENTRY org.eclipse.equinox.p2.engine 4 4 2011-03-27 21:06:30.822
!MESSAGE An error occurred while collecting items to be installed
!SUBENTRY 1 org.eclipse.equinox.p2.engine 4 0 2011-03-27 21:06:30.822
!MESSAGE session context was:(profile=profile, phase=org.eclipse.equinox.internal.provisional.p2.engine.phases.Collect, operand=, action=).
!SUBENTRY 1 org.eclipse.equinox.p2.artifact.repository 4 0 2011-03-27 21:06:30.822
!MESSAGE No repository found containing: osgi.bundle,com.example.mail,184.108.40.206103272105
!SUBENTRY 1 org.eclipse.equinox.p2.artifact.repository 4 0 2011-03-27 21:06:30.822
!MESSAGE No repository found containing: org.eclipse.update.feature,com.example.mail.core,1.0.1
Can you please help me to resolve the above problem, as why it worked in 1st scenario and failed in 2nd. I just added the entry of “instructions.configure” and it failed. Please let me know where I am going wrong.
Pingback: Eclipse RCP: Setting P2 repositories (update sites) programmatically (for when p2.inf fails). | Coopology: All things Coop.
I got this error when:
An error occurred while configuring the installed items
session context was:(profile=epp.package.java, phase=org.eclipse.equinox.internal.p2.engine.phases.Configure, operand=null –> [R], action=org.eclipse.equinox.internal.p2.engine.MissingAction).
No action found for: addRepository.
Solution was to write the qualified name “org.eclipse.equinox.p2.touchpoint.eclipse.addRepository” instead of “addRepository”
Btw: Found the hint here: http://www.eclipse.org/forums/index.php/mv/msg/41373/134442/#msg_134442
Thanks for the hint 🙂