1
votes

we have an application that will be deployed on serveral servers with different IPs. The JNLP are generated at build time. Therefore we defined the JNLP without codebase:

<jnlp spec="1.0+" href="app.jnlp">

However, when starting this application a second time (from the Desktop icon that was created on the first startup) the codebase is set to the local filesystem which is absolutely useless. I would expect that Java Webstart sets the codebase with the actual origin address when starting the Application the first time. This does not seem to be true.

How can I prepare a generic JNLP that is usable without modification on different servers?

1
If you’re generating it, why not generate a separate .jnlp file for each server? - VGR
@VGR It is generated at build time. At build time we do not know the IP addresses of the target servers. They may even change over time. - radlan
What software are the servers running? If it’s a servlet container (Tomcat, GlassFish, etc.), you can serve the .jnlp content dynamically. - VGR
@VGR Note that at this time, to be properly signed means writing the code base in the Jar as well. So for proper signing, write the codebase in the Jars, sign the Jars (for that codebase) then write the launch file to include the codebase. I'm not sure how practical it is to achieve all that dynamically (never tried it). - Andrew Thompson
@AndrewThompson You’re right. I imagine it’s possible, but pretty involved, as the servlet would need access to a keystore, password(s) for the keystore, a jarsigner binary (unless it can be done programmatically; I don’t know if it can) and the original .jar file. The spec says a signed JNLP file is optional, so I would be inclined to avoid signing it if that’s an option. - VGR

1 Answers

0
votes

The JnlpDownloadServlet available in the sample/jnlp/servlet directory of the JDK, can be used to generate the JNLP from a template at runtime, inserting the correct codebase e.g.:

<jnlp spec="1.0+" codebase="$$codebase" href="app.jnlp">

Mojohaus provided a mavenized package of the servlet here.

You also need to provide an JNLP-INF/APPLICATION_TEMPLATE.JNLP file in the signed main jar. This duplicates your app.jnlp but has an asterisk for the $$codebase:

<jnlp spec="1.0+" codebase="*" href="app.jnlp">