Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8189783

Java Web Start application with file extension association is removed from cache when invoked for the second time from browser

    Details

    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b01
    • CPU:
      x86
    • OS:
      other

      Backports

        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 ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  herrick Andy Herrick
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: