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

JNLP DownloadService API doesn't remove all resources

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 7u45
    • deploy

      FULL PRODUCT VERSION :
      java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]
      Windows 7 32 bit
      Windows 7 64 bit
      Windows Vista


      A DESCRIPTION OF THE PROBLEM :
      Our application uses Java Webstart for installation and uninstallation. We provide a link to installation JNLP file which creates following:

      - a desktop shortcut for launching a swing based application
      - Creates "Programs Menu" under Start button with
         1.application shortcut for launching application and
          2."Uninstall URL" for removing app (separate JNLP hosted on website)
          3. An entry in Control panel/Add remove programs or Programs & Features

      The Uninstall process uses JNLP DownloadService API to remove all cached resources.

      - As a part of our uninstall process we remove cache resources associated with installation JNLP (shortcut icons, desktop shortcut, programs menu etc) by calling downloadService.removeResource(installJNLPURL, null)


      - We do the same for removing the uninstall JNLP URL by downloadService.removeResource(uninstallJNLPURL, null)

      We noticed that in the latest release Java 7 u45 and some versions of Java 1.7, the application fails to uninstall completely from PC with following observations.
      1.both install and uninstall JNLP file gets deleted always (verified from JCP cache viewer)
      2. desktop shortcut, Programs Menu item and Control panel/Add remove programs or Programs & Features are not removed properly.
      DownloadService.removeResource() is not removing all the resources

      When this happens, the desktop/Programs menu launch shortcut continue to launch the application (which in the background seems to download the application resources, this is verified by going back to JCP cache viewer)

      In our current code, we make sure JNLP pass JNLP install based on the JNLP install

      REGRESSION. Last worked in version 7u21

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      launch install.jnlp which creates all shortcuts, programs menu and starts app.

      After app is installed, launch uninstall.jnlp file

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      launching uninstall.jnlp should remove the application completely from the computer. All related resources must be removed such as:
      1.both install and uninstall JNLP file
      2. desktop shortcut, Programs Menu item and Control panel/Add remove programs or Programs & Features
      ACTUAL -
      1.both install and uninstall JNLP file gets deleted always (verified from JCP cache viewer)
      2. desktop shortcut, Programs Menu item and Control panel/Add remove programs or Programs & Features are not removed properly.
      DownloadService.removeResource() is not removing all the resources


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      webstart console log:
      -------------------------------

      network: Remove cache entry: http://localhost:8080/employer/java7u45-uninstall-bug/demo.jar
      cache: MemoryCache: removed entry http://localhost:8080/employer/java7u45-uninstall-bug/demo.jar
      network: Remove cache entry:
      cache: Failed to delete: C:\Users\USER123\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\27\4742b7db-2b0ec553
      network: Remove cache entry:
      http://localhost:8080/employer/java7u45-uninstall-bug/uninstall.jnlp

      cache: MemoryCache: removed entry http://localhost:8080/employer/java7u45-uninstall-bug/uninstall.jnlp

      network: Remove cache entry:
      network: Remove cache entry: http://localhost:8080/employer/java7u45-uninstall-bug/uninstall.jnlp
      cache: Failed to delete: C:\Users\USER123\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\41\a342ae9-67a8315e

      REPRODUCIBILITY :
      This bug can be reproduced often.

      ---------- BEGIN SOURCE ----------
      ----------------------------
      | AppLauncher.java |
      ----------------------------

      package sample.demo;

      import java.awt.Dimension;
      import java.awt.Label;

      import javax.swing.JFrame;

      public class AppLauncher
      {
        public AppLauncher()
        {
          JFrame frame = new JFrame("Sample App v 1.0");
          frame.setSize(new Dimension(300, 300));
          Label label = new Label();
          label.setText("Sample App in Webstart");
          frame.add(label);
          frame.setDefaultCloseOperation(3);
          
          frame.setVisible(true);
        }
        public static void main(String[] args) {
          new AppLauncher();
        }
      }


      ----------------------------
      | AppUninstaller.java |
      ----------------------------

      package sample.demo;

      import java.awt.Dimension;
      import java.awt.Toolkit;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.awt.event.KeyEvent;
      import java.net.URL;

      import javax.jnlp.DownloadService;
      import javax.jnlp.ServiceManager;
      import javax.swing.BoxLayout;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JPanel;
      import javax.swing.SwingWorker;

      public class AppUninstaller extends JFrame {

          /** */
          private static final long serialVersionUID = 1L;

          class UninstallTask extends SwingWorker<Void, Void> {

              @Override
              protected Void doInBackground() throws Exception {

                  try {
                      DownloadService downloadService = (DownloadService) ServiceManager
                              .lookup("javax.jnlp.DownloadService");
                      URL appURL = new URL(
                              "http://localhost:8080/employer/java7u45-uninstall-bug/install.jnlp");
                      URL unInstallURL = new URL(
                              "http://localhost:8080/employer/java7u45-uninstall-bug/uninstall.jnlp");

                      if (downloadService.isResourceCached(appURL, null)) {
                          downloadService.removeResource(appURL, null);
                      }

                      downloadService.removeResource(unInstallURL, null);

                  } catch (Exception e) {
                      e.printStackTrace();
                  }
                  return null;
              }

              @Override
              public void done() {
                  getContentPane().removeAll();
                  JLabel unistallMsg = new JLabel(
                          "Sample App was uninstalled successfully.");
                  JButton button = new JButton("<html><u>O</u>K</html>");
                  button.setMnemonic(KeyEvent.VK_O);
                  button.addActionListener(new ActionListener() {

                      @Override
                      public void actionPerformed(ActionEvent e) {
                          // TODO Auto-generated method stub
                          System.exit(0);
                      }

                  });

                  JPanel msgPanel = new JPanel();
                  JPanel btnPanel = new JPanel();
                  msgPanel.add(unistallMsg);
                  btnPanel.add(button);

                  getContentPane().setLayout(
                          new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
                  getContentPane().add(msgPanel);
                  getContentPane().add(btnPanel);

                  repaint();
                  setVisible(true);
              }

          }

          public AppUninstaller() {

              setTitle("Sample App v 1.0 uninsaller");
              JLabel label = new JLabel(
                      "Please wait while Sample App is uninstalled.");
              JPanel contentPane = new JPanel();
              contentPane.add(label);
              this.setContentPane(contentPane);
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              int height = screenSize.height;
              int width = screenSize.width;

              int tempHeight = height / 10;
              if (height < 650) {
                  tempHeight = height / 6;
              } else if (height < 800) {
                  tempHeight = height / 7;
              } else if (height < 900) {
                  tempHeight = height / 8;
              }
              setSize(width / 3, tempHeight);
              setLocationRelativeTo(null);
              setVisible(true);
              UninstallTask task = new UninstallTask();
              task.execute();

          }

          public static void main(String[] args) {
              new AppUninstaller();
          }
      }

      ----------------------------
      | install.jnlp |
      ----------------------------
      <jnlp spec="6.0+" codebase="http://localhost:8080/employer/java7u45-uninstall-bug/" href="http://localhost:8080/employer/java7u45-uninstall-bug/install.jnlp">
        <information>
          <title>Sample App</title>
          <vendor>Sample Vendor name</vendor>
          <homepage href="null"/>
          <description>Sample App v 1.0</description>
          <description kind="short">Sample App</description>
          <icon href="http://localhost:8080/employer/java7u45-uninstall-bug/WRENCH.gif" kind="default"/>
          <shortcut online="true" install="true">
            <desktop/>
            <menu submenu="Sample App"/>
          </shortcut>
          <related-content href="http://localhost:8080/employer/java7u45-uninstall-bug/index.html">
            <title>Uninstall Sample App</title>
            <icon href="http://localhost:8080/employer/java7u45-uninstall-bug/uninstall.gif"/>
          </related-content>
          <offline-allowed/>
        </information>
        <security>
          <all-permissions/>
        </security>
        <update check="timeout" policy="always"/>
        <resources>
          <java initial-heap-size="134217728" max-heap-size="268435456" version="1.6+"/>
          <jar href="http://localhost:8080/employer/java7u45-uninstall-bug/demo.jar" download="eager" main="true"/>
        </resources>
        <application-desc main-class="sample.demo.AppLauncher"/>
      </jnlp>
      ----------------------------
      | uninstall.jnlp |
      ----------------------------

      <jnlp spec="6.0+" codebase="http://localhost:8080/employer/java7u45-uninstall-bug/" href="http://localhost:8080/employer/java7u45-uninstall-bug/uninstall.jnlp">
        <information>
          <title>Sample App</title>
          <vendor>Sample Vendor name</vendor>
          <homepage href="null"/>
          <description>Sample App v 1.0</description>
          <description kind="short">Sample App</description>
          <offline-allowed/>
        </information>
        <security>
          <all-permissions/>
        </security>
        <update check="timeout" policy="always"/>
        <resources>
          <java initial-heap-size="134217728" max-heap-size="268435456" version="1.6+"/>
          <jar href="http://localhost:8080/employer/java7u45-uninstall-bug/demo.jar" download="eager" main="true"/>
        </resources>
        <application-desc main-class="sample.demo.AppUninstaller"/>
      </jnlp>


      NOTE: please choose any image gif files
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      ???Select the ???Start??? menu on the left hand corner of your computer screen. Select Control Panel ?????? Programs ?????? Programs and Features, and select the software from the menu. Right click on the software and uninstall from your computer.


      SUPPORT :
      YES

            alitvinov Anton Litvinov (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: