JDK-8189783 : Java Web Start application with file extension association is removed from cache when invoked for the second time from browser
  • Type: Bug
  • Component: deploy
  • Sub-Component: webstart
  • Affected Version: 8u141
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: other
  • CPU: x86
  • Submitted: 2017-10-18
  • Updated: 2018-10-23
  • Resolved: 2018-04-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8u181Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 8.1 Enterprise. Also fails in Mac OS X El Capitan 10.11.4

A DESCRIPTION OF THE PROBLEM :
We have a Web Start application that manages a custom file format by using "association" element of the JNLP file of the application.

The application is working the first time I open this custom files form a browser, but it shows the next error the following times:

CouldNotLoadArgumentException[ No se ha podido cargar la URL ni el archivo especificado: C:\Users\plyca\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\38\1784126-7e5634a4]
	at com.sun.javaws.Main.launchApp(Unknown Source)
	at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
	at com.sun.javaws.Main.access$000(Unknown Source)
	at com.sun.javaws.Main$1.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\Users\plyca\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\38\1784126-7e5634a4 (El sistema no puede encontrar el archivo especificado)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
	... 5 more

It seems that the application is removed from the cache path where it was saved the first time.

This problem doesn't occurs when I open the file several times from the file system. Maybe a problem whit the browser plugin implementation?.

I have developed a demo application, packaged as a war, that you can use to reproduce this behavior.


REGRESSION.  Last worked in version 7u80

ADDITIONAL REGRESSION INFORMATION: 
It works with versions prior to:

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

And seems to be broken with "1.8.0_141" version.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Install the provided war example in a server
2. Install de application from the link provided in http://server/test
3. Click in the link provided in http://server/test to open the example application. Open downloaded file from the browser.
4. Click again in the same link described in step 3.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The application is opened every time I download and open this kind of files from the browser
ACTUAL -
The first time the application opens a Frame that shows the text content of the downloaded file.

The second time it is not being launched because the application no longer exists in the cache path where the application was first saved.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
CouldNotLoadArgumentException[ No se ha podido cargar la URL ni el archivo especificado: C:\Users\plyca\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\38\1784126-7e5634a4]
	at com.sun.javaws.Main.launchApp(Unknown Source)
	at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
	at com.sun.javaws.Main.access$000(Unknown Source)
	at com.sun.javaws.Main$1.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\Users\plyca\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\38\1784126-7e5634a4 (El sistema no puede encontrar el archivo especificado)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at java.io.FileInputStream.<init>(Unknown Source)
	at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
	... 5 more

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
1.JNLP File

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0" codebase="$$codebase" version="1.0.0" href="test.jnlp">
  <information>
	  <title>Web Start test</title>
	  <vendor>ACME</vendor>
	  <description>Web Start file association test</description>
	  <association extensions="test" mime-type="application/x-test"/>
  </information>
  <security>
     <all-permissions/>
  </security>
  <update check="timeout" policy="always"/>  
  <resources>
  	<j2se version="1.8"/>
    <jar href="test-webstart.jar" download="eager" main="true"/>
    <jar href="commons-io-2.2.jar" download="eager"/>
  </resources>
  <application-desc main-class="com.nexusit.test.TestFrame"/>
</jnlp>

2. Example page

<!doctype html>
<html lang="en">
<head>
    <title>Web Start file association example</title>
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />   
    <meta http-equiv="pragma" content="no-cache" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">    
</head>
<body>
	<p>Press this <a href="test.jnlp">link</a> to install Web Start application.</p>
    <p>Press this <a href="file.test">link</a> to open Web Start from browser.</p>
</body>
</html>

3. Example file content (file.test)

"This is an example file"

4. web.xml

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	version="2.5">

	<servlet>
		<servlet-name>JnlpDownloadServlet</servlet-name>
		<servlet-class>jnlp.sample.servlet.JnlpDownloadServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>JnlpDownloadServlet</servlet-name>
		<url-pattern>*.jnlp</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>JnlpDownloadServlet</servlet-name>
		<url-pattern>*.jar</url-pattern>
	</servlet-mapping>
	<mime-mapping>
		<extension>test</extension>
		<mime-type>application/x-test</mime-type>
	</mime-mapping>
	<mime-mapping>
		<extension>jnlp</extension>
		<mime-type>application/x-java-jnlp-file</mime-type>
	</mime-mapping>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
	</welcome-file-list>
</web-app>

5. Application code:

package com.nexusit.test;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

import org.apache.commons.io.FileUtils;

public class TestFrame extends JFrame {
	
	private static final long serialVersionUID = 2681884653385621373L;

	public TestFrame(File file) {
		//1. Create the frame.
		super("Test Frame");
		//2. Optional: What happens when the frame closes?
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//3. Create components and put them in the frame.
		JLabel title = new JLabel("File content");
		getContentPane().add(title, BorderLayout.NORTH);
		String fileContent = null;
		if (file!=null && file.exists()) {
			try {
				fileContent = FileUtils.readFileToString(file);
			} catch (IOException e) {
				fileContent = "Error readinf file "+file;
			}
		} else {
			fileContent = "File does not exists";
		}
		JLabel fileContentLabel = new JLabel(fileContent);
		getContentPane().add(fileContentLabel, BorderLayout.CENTER);
		setPreferredSize(new Dimension(400,300));
		pack();
	}
	
	public static void main(final String args[]) throws ParseException {
		SwingUtilities.invokeLater(new Runnable() {

			public void run() {
				try {
					if (args.length > 0) {
						String fileName = null;
						if (args.length == 1) {
							// open with main
							fileName = args[0];
						} else {
							// open with webstart
							fileName = args[1];
						}		
						File file = null;
						if (fileName != null) {
							file = new File(fileName);	
						}					
						new TestFrame(file).setVisible(true);
					}
				} catch (Throwable e) {
					e.printStackTrace();
				}
			}
		});

	}

}





---------- END SOURCE ----------


Comments
CPU18_07-critical-request - Justification : customer escalation - Risk Analysis : Low. - Testing (done/to-be-done) : Tested by manually running above test apps - Back ports (done/to-be-done) : none - FX Impact : N/A - Fix For Release : 8u181
17-04-2018

The NPE is caused by the lines in LocalInstallHandler.registerAssociations() : String newCommand = getOpenActionCommand(extAssoc); if (newCommand.equals(command)) { This can easily be fixed by checking if the newCommand returned is null.
11-04-2018

the users example uses the jnlp download servlet to dynamically generate the jnlp file, which has: <jnlp spec="6.0" codebase="$$codebase" version="1.0.0" href="test.jnlp"> without using the jnlp servlet, I think I can reproduce the problem. 1.) I have two apps, both register the ".poon1" extension with different mime-types ("application/x-poon1-mime" vs "application/poon1-mime" A) http://oklahoma.us.oracle.com/www/tests/javaws/generic/assoc/test.jnlp (has "application/x-poon1-mime") B) http://oklahoma.us.oracle.com/www/tests/javaws/generic/assoc/test1.jnlp (has "application/poon1-mime" 2.) search registry and delete any entries referencing "poon1" 3.) run A, allow it to register mimetype, confirm that clicking on poon1 file on desktop will launch test.jnlp 4.) run B, allow it to replace mimetype, confirm that clicking on poon1 file on desktop will launch test1.jnlp 5.) now run "javaws -uninstall" - this is where the problem begins, poon1 entries in registry are only partially removed. 6.) now run A, allow it to register mimetype - you will see NPE in console, and trying to launch ".poon1" file from desktop will fail as described in the description above (can't find file) when A is run the following registry keys are created: HKCU/Software/Classes/.poon1 HKCU/Software/Classes/classpoon11 HKCU/Software/Classes/classpoon11/DefaultIcon HKCU/Software/Classes/classpoon11/shell HKCU/Software/Classes/classpoon11/shell/open HKCU/Software/Classes/classpoon11/shell/open/command HKCU/Software/Classes/classpoon11/shell/print HKCU/Software/Classes/classpoon11/shell/print/command HKCU/Software/Classes/MIME/Database/Content Type/application\x-poon1-mime if you then run "javaws -uninstall" all these will be removed. if instead you run A then B (allowing mime-type replacement) you will then have both HKCU/Software/Classes/MIME/Database/Content Type/application\poon1-mime and HKCU/Software/Classes/MIME/Database/Content Type/application\x-poon1-mime running "javaws -uninstall" after that will only remove "application\poon1-mime" and leave "application\x-poon1-mime" behind. This causes an NPE when running A again and trying to register the association: java.lang.NullPointerException at com.sun.javaws.LocalInstallHandler.registerAssociation(Unknown Source) at com.sun.javaws.LocalInstallHandler.createAssociations(Unknown Source) at com.sun.javaws.LocalInstallHandler.performIntegration(Unknown Source) at com.sun.javaws.LocalInstallHandler.install(Unknown Source) and this NPE leaves the association in the broken state described in the description.
11-04-2018

I get same results in 8u151, except jnlp file doesn't move in the cache, so registry doesn't need to be updated - I will try modifying jnlp file so it moves in cache with 151, and see if registry is properly updated before installing full tomcat to run app as originally described. yes - when property is added to jnlp file on web - cache is updated - and registry is updated to reflect the changed jnlp location in cache. So still cannot reproduce.
31-01-2018

I can see in registry, running 8u162, that associan mime-type in registry is updated to point to the new jnlp file in the cache each time the app is run. I cannot, however, get the simple example at http://oklahoma.us.oracle.com/www/tests/javaws/generic/assoc/ to work at all: When running test1.jnlp, I then see poon1 extension and mime-type in the registry, but accessing test.poon1 in any way just brings up browser. I see in registry: HKCU/Software/Classes/.poon1/Default is "classpoon11", and HKCU/Software/Classes/.poon1/Content type is "application/x-poon1-mime", and HKCU/Software/Classes/classpoon11/Shell/Open/Command/Default is: "C:\Program Files\Java\jre1.8.0_162\bin\javaws.exe" "-localfile" "-open" "%1" "C:\Users\aherrick.ORADEV\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\12\d244e0c-4cd3c395" where the final path is path to jnlp file in the cache. If I re-run the app the registry entry for HKCU/Software/Classes/classpoon11/Shell/Open/Command/Default gets re-written to point to new location of the revised jnlp file in the cache. will re-try with 8u151.
31-01-2018

example uses the jnlp download servlet, so jnlp file is re-generated on each run. when associated file is first run the app gets a new jnlp file for the same url, and caches it in new location in the cache. Special care that is used in these cases to update shortcut to app should be applies similarly to associations.
23-10-2017

Reported with JDK 8u141 Windos 8.1/MAC OS X El Capitan (10.11.4) The JWS application with file extension association is removed from cache when invoked repeatedely from the browser. Checked this for JDK When checked with multiple Java versions could confirm the regression fron 8u141. Results: ========== 7u80 - OK 8 - OK 8u91 - OK 8u121 - OK 8u131 - OK 8u141 - FAIL 8u151 - FAIL 9 - FAIL (fail to launch the first time) Run with JDK 8u151: ========================== CouldNotLoadArgumentException[ Could not load file/URL specified: C:\Users\abc\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\2\275e3902-1b8d5c2b] at com.sun.javaws.Main.launchApp(Unknown Source) at com.sun.javaws.Main.continueInSecureThread(Unknown Source) at com.sun.javaws.Main.access$000(Unknown Source) at com.sun.javaws.Main$1.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.io.FileNotFoundException: C:\Users\abc\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\2\275e3902-1b8d5c2b (The system cannot find the file specified) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source) ... 5 more ================================= This is a regression introduced in JDK 8u141. To verify run the war file provided in the link in subsequent comment. Additional Steps: 1. Install the war into a web server (http://localhost:8080/test) 2. Install the application from the first provided link in the web page. 3. Click in the subsequent link provided in http://localhost:8080/test/ to open the example application. Open downloaded file from the browser. 4. Close the window with text file example. 5. Repeat the step 3 again in the same link described in step 3.
23-10-2017