Java Web Start always caches JNLP file in Windows XP

At my company, we use Java Web Start to distribute client software to clients. They use different versions of Windows: XP, Vista, and 7.

We deployed the version via JWS with minimal problems in the past. Our latest release includes several file changes, some banks are gone, others have appeared, etc.

We found that the update on computers running Windows XP fails because JWS is still trying to find jar files that are no longer available on the web server. I checked my HTTP server log and the JNLP file never gets access to XP computers when the application starts. If I try the same in Vista or Windows 7, everything will work fine, JWS retrieves the JNLP handle and loads the differences when an update is available. Thus, on XP computers, only known jar files are updated, and JWS throws an error if it does not find something from the cached set of JNLP files.

I wrote a servlet that manually creates a JNLP file. I use the following header configuration in my servlet code.

response.setDateHeader("Last-Modified", lastModification); // IE won't download JNLP file if Cache-Control header presents //response.setHeader("Cache-Control", "no-cache, must-revalidate"); response.setHeader("Expires", "Mon, 26 Jul 1990 05:00:00 GMT"); 

This makes the JNLP file always obsolete, which should trigger a re-check of the file every time the client starts through JWS. I even see this date in the cache viewer in XP:

Cache viewer

I found a problem that was never resolved on the Oracle bugreport website: Error ID: 6189106 Just tested the same with Java7 in Windows XP, but this problem still exists. But only on XP because of the space characters in the path to the deployment cache ("Documents and Settings" you know). Someone says that if I change the path to the deployment cache to something that does not contain spaces, it will solve the problem. Well, this is not a real solution, because users are unlikely to ever write in places other than their profile.

Since this error has existed for such a long time, I think there should be some workaround. I don’t like to tell the client every time to clear the Java cache and reinstall the application from the Internet. We would like to move on to a faster release cycle in the future, which will make it even more serious. Hope someone has a good idea .: |

+8
java java-web-start distribution
source share
2 answers

The problem is the cache path of the java website. If it contains spaces (this is exactly the same in XP), then the path is transferred in the wrong format in javaws, and this blocks checking for updates to the jnlp file.

Change this path in the deployment.properties file as follows:

deploy.user.cachedir = C \: \ your \ path - this path should not contain spaces.

PS Before that, clear the Java cache.

Added: The problem appears after update 21.

+5
source share

I got a hacker solution:

  • Put the version number in your JNLP file, passing it as an argument to your main method (for example, <argument>1.0</argument> ). Alternatively, you can pass an explicit timestamp.

  • Check a) the system property java.version or javawebstart.version to see if your application is running on anything between 1.6.0_22 and 1.7.0_2 (inclusive); and b) check the system property deployment.user.cachedir to see if there are any spaces in it. If a) and b) are not correct, then there is probably no point in continuing with the following steps: Java Web Start should check the JNLP file for updates.

  • When launched, before showing any forms, load the JNLP file into memory (for example, using new URL(jnlpUrlString).openStream() , etc.). I pass the URL of the JNLP file to my application as an argument from the JNLP file itself, for example, for the version number.

  • Check the JNLP file to see if it contains the version number that was passed to your main method (for example, a simple string search for "<argument>" + versionNumberPassedIntoMainMethod + "</argument>" ). If so, you're good to use the latest version. If not, continue:

  • Save the JNLP file in the temp directory (for example, using File.createTempFile(...) ).

  • Get the system to open the JNLP file from a temporary directory, for example. with java.awt.Desktop.getDesktop().open(jnlpFile) if you are targeting Java 1.6 +.

  • System.exit(0) to close the outdated version of the application and let the updated take over.

I also save and check the last boot date in the registry (using java.util.prefs.Preferences ) to prevent multiple downloads or reopening in short order. The idea is to reduce the chance of an error in my code by causing something too unpleasant, like an endless check loop with open checks-re-check-re-check, etc. And I upload a JNLP file with a timeout so that a slow connection can't prevent the application from opening for too long. But these are just additional options.

Since my application works with <security><all-permissions/><security/> , it has no problems downloading the JNLP file, saving it to the computer, and opening it using the default program. You can probably find workarounds for each of these steps using the javax.jnlp library so you don't need all the permissions, but I'm not too sure about that.

In general, for me, this approach works very well. But I still hope for a day when Java Web Start errors like this are a thing of the past, as this hacker nonsense is really unnecessary.

+5
source share

All Articles