United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6431929 : Classloader.getResource behaves differently

Details
Type:
Bug
Submit Date:
2006-05-30
Status:
Closed
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2006-05-31
Component:
deploy
OS:
windows_xp
Sub-Component:
webstart
CPU:
x86
Priority:
P3
Resolution:
Not an Issue
Affected Versions:
6
Fixed Versions:

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b83)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b83, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When locating a resource in a jar getResource returns the jarfile on the server instead of the file in the webstart cache


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Have a classloader locate a resource in a jar file to figure out where the jar file is located

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
resourcePath should be something like
jar:file:/C:/Documents and Settings/BS/Application Data/Sun/Java/Deployment/cache/javaws/http/Ddkegh408/P8046/DMV3R1/DMDev/DMeXposer/RMconfig.jar!/eXposer.properties
ACTUAL -
jar:file:/dkegh408:8046/V3R1/Dev/eXposer/config.jar!/eXposer.properties

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package webstartapplication;

public class Main {
    
    /** Creates a new instance of Main */
    public Main() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        ClassLoader cl = Main.class.getClassLoader();
        String resourcePath = cl.getResource("test.properties").toString();
        System.out.println("resourcePath = " + resourcePath);
    }
    
}

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc.//DTD JNLP 1.5//EN" "http://www.netbeans.org/jnlp/DTD/jnlp.dtd">
<jnlp codebase="$$codebase" href="WebstartApplication.jnlp">
  <information>
    <title>WebstartApplication</title>
    <vendor>Company, Inc.</vendor>
    <homepage href="homepage.html"/>
    <description> </description>
    <icon href="default"/>
    <offline-allowed/>
  </information>
  <resources>
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
  </resources>
  <resources>
    <jar download="eager" href="WebstartApplication.jar" main="false"/>
  </resources>
  <application-desc main-class="webstartapplication.Main"/>
</jnlp>

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

Release Regression From : 5.0
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

                                    

Comments
EVALUATION

The original behavior was a bug (returning the jar url to the file url in the cache) and caused a lot of problems.  The new behavior of getResource() is differant, because this bug has been removed.
see: 5072943
                                     
2006-05-31



Hardware and Software, Engineered to Work Together