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

Loading a pack200 JAR with JarURLConnection.getJarFile() leads to IOException

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • 7u21
    • 7u21
    • deploy
    • b11
    • windows_7

    Description

      FULL PRODUCT VERSION :
      java version " 1.7.0_21 "
      Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
      Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode, sharing)

      This also occurs with Java 1.7.0_17.

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601], also occurs on OS X 10.8.3 and other Windows versions. Not tested on linux.

      A DESCRIPTION OF THE PROBLEM :
      When loading an additional JAR from an applet with -Djnlp.packEnabled=true by using JarUrlConnection.getJarFile() an " java.io.IOException: Invalid jar file " is thrown.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a JAR from the test case (testapplet.jar)
      2. Sign and pack200 the JAR (testapplet.jar.pack.gz)
      3. Create a copy of the normal and pack200 version of the JAR and name them " additional.jar " and " additional.jar.pack.gz "
      4. Create HTML file to load the applet by using the testapplet.jar(.pack.gz) file. All JAR files should be on the same directory (code base).
      5 Open the HTML in a browser, set trace level to 5.

      OR use the test case at:

      http://www.realobjects.com/fileadmin/products/testapplet/oracle-bug2/pack200.html

      For IE
      http://www.realobjects.com/fileadmin/products/testapplet/oracle-bug2/pack200-ie.html

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No exception, JAR can be loaded and accessed
      ACTUAL -
      Exception, JAR is not loaded correctly

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Java Plug-in 10.21.2.11
      Using JRE version 1.7.0_21-b11 Java HotSpot(TM) Client VM
      User home directory = C:\Users\sebastian.giffhorn
      ----------------------------------------------------
      c: clear console window
      f: finalize objects on finalization queue
      g: garbage collect
      h: display this help message
      l: dump classloader list
      m: print memory usage
      o: trigger logging
      q: hide console
      r: reload policy configuration
      s: dump system and deployment properties
      t: dump thread list
      v: dump thread stack
      x: clear classloader cache
      0-5: set trace level to <n>
      ----------------------------------------------------
      basic: Starting applet teardown
      basic: Finished applet teardown
      basic: PluginMain.unregisterApplet: 1 from mananger sun.plugin2.applet.Applet2Manager@a21ac2
      basic: Removed progress listener: sun.plugin.util.ProgressMonitorAdapter@11cc36
      security: --- parseCommandLine converted : -Xmx256m -Djnlp.packEnabled=true
      into:
      [-Xmx256m, -Djnlp.packEnabled=true]
      basic: Added progress listener: sun.plugin.util.ProgressMonitorAdapter@aafcb8
      basic: Plugin2ClassLoader.addURL parent called for http://sgmac/workspaces/eclipse/Pack200%20Applet-LoadJAR/testapplet.jar
      security: Validate the certificate chain using CertPath API
      security: SHA-256 finger print: 6BE7B7BB9E9DBCC0E168FC768727256F0DD54D97FF09172E3B592AE3347CE0D5
      security: SHA-256 finger print: AF840CA2B9DFB776BF81AA94C401BC440C52E5C590C43607A13D6680D83E3349
      security: SHA-256 finger print: 8D722F81A9C113C0791DF136A2966DB26C950A971DB46B4199F4EA54B78BFB9F
      security: The certificate hasnt been expired, no need to check timestamping info
      security: The CRL support is disabled
      security: The OCSP support is disabled
      security: This OCSP End Entity validation is disabled
      network: Created version ID: 1.7.0.21
      network: Created version ID: 1.7.0.21
      basic: Applet loaded.
      basic: Applet resized and added to parent container
      basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 325625 us, pluginInit dt 19861476 us, TotalTime: 20187101 us
      ***** Before getJarFile
      network: Connecting http://sgmac/workspaces/eclipse/Pack200%20Applet-LoadJAR/additional.jar.pack.gz with proxy=DIRECT
      network: Connecting http://sgmac:80/ with proxy=DIRECT
      network: Connecting http://sgmac/workspaces/eclipse/Pack200%20Applet-LoadJAR/additional.jar.pack.gz with proxy=DIRECT
      network: Connecting http://sgmac:80/ with proxy=DIRECT
      network: ResponseCode for http://sgmac/workspaces/eclipse/Pack200%20Applet-LoadJAR/additional.jar.pack.gz : 200
      network: Encoding for http://sgmac/workspaces/eclipse/Pack200%20Applet-LoadJAR/additional.jar.pack.gz : null
      network: Server response: (length: 5052, lastModified: Mon May 06 15:40:37 CEST 2013, downloadVersion: null, mimeType: application/x-gzip)
      network: Downloading resource: http://sgmac/workspaces/eclipse/Pack200%20Applet-LoadJAR/additional.jar.pack.gz
      Content-Length: 5.052
      Content-Encoding: pack200-gzip
      network: Disconnect connection to http://sgmac/workspaces/eclipse/Pack200%20Applet-LoadJAR/additional.jar.pack.gz
      java.io.IOException: Invalid jar file
      at com.sun.deploy.net.HttpDownloadHelper.download(Unknown Source)
      at com.sun.deploy.net.DownloadEngine.downloadResourceToTempDir(Unknown Source)
      at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
      at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
      at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
      at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
      at sun.plugin.PluginURLJarFileCallBack$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.plugin.PluginURLJarFileCallBack.retrieve(Unknown Source)
      at sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source)
      at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
      at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
      at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
      at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(Unknown Source)
      at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFileInternal(Unknown Source)
      at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(Unknown Source)
      at TestApplet.init(Unknown Source)
      at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
      com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://sgmac/workspaces/eclipse/Pack200%20Applet-LoadJAR/additional.jar
      at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
      at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
      at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
      at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
      at sun.plugin.PluginURLJarFileCallBack$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.plugin.PluginURLJarFileCallBack.retrieve(Unknown Source)
      at sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source)
      at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
      at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
      at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
      at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(Unknown Source)
      at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFileInternal(Unknown Source)
      at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(Unknown Source)
      at TestApplet.init(Unknown Source)
      at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
      Caused by:
      java.io.IOException: Invalid jar file
      at com.sun.deploy.net.HttpDownloadHelper.download(Unknown Source)
      at com.sun.deploy.net.DownloadEngine.downloadResourceToTempDir(Unknown Source)
      at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
      at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
      at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
      at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
      at sun.plugin.PluginURLJarFileCallBack$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.plugin.PluginURLJarFileCallBack.retrieve(Unknown Source)
      at sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source)
      at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
      at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
      at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
      at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(Unknown Source)
      at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFileInternal(Unknown Source)
      at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(Unknown Source)
      at TestApplet.init(Unknown Source)
      at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
      at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
      basic: Applet initialized
      basic: Starting applet
      basic: completed perf rollup
      basic: Applet made visible
      basic: Applet started
      basic: Told clients applet is started


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.net.JarURLConnection;
      import java.net.URL;
      import java.util.jar.JarFile;

      import javax.swing.JApplet;

      public class TestApplet extends JApplet {
          
          
          public void init() {
              try {
                  JarURLConnection uc = null;
                  URL url = null;
                  url = new URL(getCodeBase(), " additional.jar " );
                  url = new URL( " jar " , " " , url + " !/ " );
                  uc = (JarURLConnection) url.openConnection();
                  System.out.println( " ***** Before getJarFile " );
                  JarFile jf = uc.getJarFile();
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }

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

      Attachments

        Activity

          People

            bae Andrew Brygin
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: