A Maven configuration for a Java Webstart (JNLP) application – 2

In a previous post I detailed the Maven configuration to generate a Java Webstart application using the webstart-maven-plugin along with the maven-shade-plugin (the shade plugin allows to generate auto-executable jars).

I faced some troubles when I tried to use this configuration in another application requiring access to system resources (accessing files and directories for read and write operations) and using third party trusted libraries:

When the application needs grant access system resources, you must ask for that grant through the all-permissions configuration element in the jnlp file

<security>
     <all-permissions/>
</security>

However, to do this, you must sign all the jars: the application jar and the third party jars the application needs, and generally the third party jars you are using are signed and this makes the maven-shade-plugin fail when processing the whole. Even more, if the whole application is not signed with the same certification authority, it will fail executing on the client side.

So I ended up with this webstart-maven-plugin configuration (which happens to be even simpler than the one on my previous post):

<plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>webstart-maven-plugin</artifactId>
 <version>1.0-beta-3</version>
 <executions>
  <execution>
  <id>package</id>
  <phase>package</phase>
  <goals>
   <goal>jnlp</goal>
  </goals>
  <configuration>
   <codebase>${jnlp.URL}</codebase>
   <jnlp>
    <mainClass>${mainClass}/mainClass>
   </jnlp>
   <pack200>true</pack200>
   <sign>
    <keystore>${jks.filPath}</keystore>
    <keypass>${jks.keyPass}</keypass>
    <storePass>${jks.storePass}</storepass>
    <alias>${jks.alias}</alias>
    <verify>false</verify>
    </sign>
    <unsignAlreadySignedJars>true</unsignAlreadySignedJars>
   </configuration>
  </execution>
 </executions>
</plugin>

Note also that there is no need to the maven-shade-plugin.

The unsignAlreadySignedJars property allows to unsign the third party libraries you are using, and signing them again with your signing configuration.

Replace in the above plugin configuration the ${jnlp.URL}, ${mainClass} and ${jks.X} parameters with yours.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s