A Maven configuration for a Java Webstart (JNLP) application


  • codehaus Maven JNLP plugin version 1.0-beta-3
  • Maven shade plugin version 1.6

The Plugin configuration to generate auto-executable Jar

                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">

The Plugin configuration for JNLP (via a profile)


You have to change these configurations according to your application, mainly the codebase, the mainClass (in both plugins configurations) and the keystore parameters to use your own

In order to generate the JNLP repository, run

    mvn clean install -Pjnlp

A jnlp folder is created in the target folder containing all the needed resources and the “launch.jnlp” autostart file.

It is important to put the “jnlp” velocity template.vm file in src/main/jnlp along with the keystore file.

The pom file contains other jnlp configuration properties that you should set accordingly

  • project.name
  • project.description
  • project.url
  • project.organization.name
  • project.organization.url




Eclipse RCP and P2 Headless Update on Startup

I am no more working on Eclipse RCP … since few years now! And this seems not working on recent versions of Eclipse RCP platform (> 4.x) …

Please refer to a very good reference for that Vogella Eclipse RCP articles

This post is neither a tutorial on how to build Eclipse RCP applications nor how to create Eclipse RCP plugins and features, it is a tutorial on how to make and configure an Eclipse RCP application check for updates on startup.


  • Eclipse 3.7 platform
  • Java 6

Basic example project layout

The plugin project

Add the following dependencies to your plugin

  • org.eclipse.equinox.p2.core
  • org.eclipse.equinox.p2.operations
  • org.eclipse.equinox.p2.repository
  • org.eclipse.equinox.p2.metadata

plugin dependencies

Copy the following classes to your plugin src folder

Override the postWindowOpen method of your ApplicationWorkbenchWindowAdvisor class and add in the following code

public void postWindowOpen() {
    BundleContext bundleContext = Activator.getDefault().getBundle().getBundleContext();
    ServiceReference<IProvisioningAgent> serviceReference =   bundleContext.getServiceReference(IProvisioningAgent.class);
    IProvisioningAgent agent = bundleContext.getService(serviceReference);
    if (agent == null) {
        System.out.println(">> no agent loaded!");
    // Adding the repositories to explore
    if (! P2Util.addRepository(agent, "http://localhost/p2/repository")) {
        System.out.println(">> could no add repostory!");
    // scheduling job for updates
    UpdateJob updateJob = new UpdateJob(agent);

The feature project

Declare your startup plugin into your feature and add in the following plugins

  • com.ichir.projects.p2update.plugin1 (the plugin we’ve created earlier)
  • org.eclipse.core.net
  • org.eclipse.equinox.ds
  • org.eclipse.equinox.p2.core
  • org.eclipse.equinox.p2.director
  • org.eclipse.equinox.p2.engine
  • org.eclipse.equinox.p2.metadata
  • org.eclipse.equinox.p2.metadata.repository
  • org.eclipse.equinox.p2.publisher
  • org.eclipse.equinox.p2.publisher.eclipse
  • org.eclipse.equinox.p2.repository
  • org.eclipse.equinox.p2.repository.tools
  • org.eclipse.equinox.simpleconfigurator
  • org.eclipse.osgi
  • org.eclipse.ui.forms
  • org.eclipse.swt.win32.win32.x86

The org.eclipse.swt.win32.win32.x86 plugin depends of course on your platform.

feature dependencies

The .product configuration file

Make your product configuration depends on feature and add in the following features

  • org.eclipse.rcp
  • org.eclipse.equinox.p2.rcp.feature
  • com.ichir.projects.p2update.feature1 (the feature we’ve created earlier)

P2 Product dependencies

Specify the following starting levels in your product file

Product start configuration


When building Eclipse RCP with auto update features, versioning plugins, features and product is a major part! Each time you want to publish an update on a plugin, its version must be augmented, and so its containing feature and the product file. For simplicity, we can add the “.qualifier” to all our versions to automatically augment the version numbers each build is made.

Exporting application, generating the P2 repository and testing

  1. From the .product file, export the application with caution to check “Generate metadata repository” option. This will generate the executable application aside with a repository folder. Just ignore that repository.
  2. Make any modification to your UI and re-export the application to another folder. This time ignore the generated application and copy the generated repository to your HTTP web server (remember that we added “http://localhost/p2/repository&#8221; as an update repository in ApplicationWorkbenchWindowAdvisor)
  3. Once your application restarted, you should be prompted for an update!

That’s done! Enjoy!

To complete

To complete

Obtaining a JDBC Connection in Hibernate and OpenJPA

This post is on how to obtain/instantiate a JDBC connection in Hibernate framework or in OpenJPA framework.

Test context

  • Hibernate 3.x
  • OpenJPA 1.2.x


Session session = new Configuration().buildSessionFactory().openSession();
session.doWork(new Work() {
    public void execute(Connection connection) throws SQLException {
        // do something with connection


EntityManager manager = getEntityManagerFactory("unit-name").createEntityManager();
Connection connection = (Connection) OpenJPAPersistence.cast(manager).getConnection();
// do something with connection