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

Missing slash on resource URLs with Java WebStart

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 6
    • 6
    • deploy
    • x86
    • windows_2000



      Name: gm110360 Date: 07/21/2004


      FULL PRODUCT VERSION :
      Java Web Start 1.4.2 Console, started Thu Jan 08 15:47:29 MST 2004
      Java 2 Runtime Environment: Version 1.4.2_01 by Sun Microsystems Inc.

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      WebStart does not report a valid URL for resources.

      Execute the following code:

      System.out.println(getClass().getClassLoader().getResources("resourcename"));

      When running this in 1.4.2_05 and J2se 5.0-beta2 from the command line you will get a URL that looks like this:

      jar:file:/C:/myjar.jar!/resourcename

      However, execute this same code when running inside WebStart and you get:

      jar:file:C:/Documents%20and%20Settings/username/.javaws/cache/http/Dhost/Pport/RMmyjar.jar!/resourcename

      Note the missing forward-slash after the protocol

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a JAR with the class file and a sample test.txt resource file.
      2. Execute this with command line java -jar resource.jar
      3. Execute the same JAR under webstart using the sample JNLP file provided.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      jar:file:/C:/Documents%20and%20Settings/username/.javaws/cache/http/Dhost/Pport/RMmyjar.jar!/resourcename
      ACTUAL -
      jar:file:C:/Documents%20and%20Settings/username/.javaws/cache/http/Dhost/Pport/RMmyjar.jar!/resourcename

      There is a missing slash after "file:"

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * ResourceLoader.java
       *
       * Created on July 21, 2004, 10:18 AM
       */

      package examples.resource;

      /**
       *
       * @author gmanwani
       */
      public class ResourceLoader {
          
          /** Creates a new instance of ResourceLoader */
          public ResourceLoader() {
              try {
                  System.out.println(getClass().getClassLoader().getResource("examples/resource/test.txt"));
              } catch(Exception e) {
                  e.printStackTrace();
              }
          }
          
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              ResourceLoader rl = new ResourceLoader();
              System.exit(0);
              // TODO code application logic here
          }
          
      }

      ------ JNLP file --------
      <jnlp spec="1.0" codebase="http://javaweb.sfbay.sun.com/~gmanwani">
         <information>
            <title>Test 1.0</title>
            <vendor>Sun Microsystems, Inc.</vendor>
         </information>
         <resources>
            <j2se version="1.3+" href="http://java.sun.com/products/autodl/j2se"/>
            <jar href="resource.jar"/>
         </resources>
         <application-desc main-class="examples.resource.ResourceLoader"/>
      </jnlp>
      ------ JNLP file end ---------
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Look for the missing forward-slash and add it back programatically.
      (Incident Review ID: 233495)
      ======================================================================

            herrick Andy Herrick (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: