title: Java WebStart slow, requesting libraries from invalid folder
body: <p>Problem and question: Java webstarted app looking for its classes in base folder instead of ./lib.</p>
  
  <p>As suggested in similar question  at <a href="https://stackoverflow.com/q/3428704/683035">Java Web Start applications ask repeatedly for un-existing files</a> I have turned <strong>off</strong> the jar signing, to rule out the security issue, and the problem persists.</p>
  
  <p>Below find the clean example on what is going over the network for this simple java program:</p>
  
  <pre><code>public static void main(String[] args) {
      // TODO code application logic here
      System.out.println("Hello World! Initializing the class from the jar residing in lib/ folder. Expecting heavy network traffic...");
  
      //This class resides in lib/SampleJavaLibrary.jar
      //Initializing it just to excercise the class loader problem
      CDummyClass sDummy = new CDummyClass();
  
      System.out.println("Done");
  
  }
  </code></pre>
  
  <p>On the network (by wireshark), one can observe repeated requests for jars in base folder, On some calls I counted up to 10 retries, replied by web server with 404. Ultimately, the loadClass is successful, but only after 10 or more requests for nonexisting jars. Multiply this with the number of classes being accessed in given program, and you end up with very slow initialization.
  In this simple case, there are "only" 2 retries for this simple class.</p>
  
  <p>It all starts normal, the jars are loaded, all is good and nice:</p>
  
  <pre><code>6   0.020921    192.168.1.35    192.168.1.130   HTTP    GET /mnt/vbox/workspace/WebStartSample/distC/launch.jnlp HTTP/1.1
  8   0.028092    192.168.1.130   192.168.1.35    HTTP    HTTP/1.1 200 OK  (application/x-java-jnlp-file)
  10  0.514038    192.168.1.35    192.168.1.130   HTTP    GET /mnt/vbox/workspace/WebStartSample/distC/lib/SampleJavaLibrary.jar HTTP/1.1 
  11  0.520688    192.168.1.130   192.168.1.35    HTTP    HTTP/1.1 200 OK  (application/java-archive)
  12  0.618640    192.168.1.35    192.168.1.130   HTTP    GET /mnt/vbox/workspace/WebStartSample/distC/WebStartSample.jar HTTP/1.1 
  14  0.652541    192.168.1.130   192.168.1.35    HTTP    HTTP/1.1 200 OK  (application/java-archive)
  </code></pre>
  
  <p>This is where the trouble begins, at library class call:</p>
  
  <pre><code>16  0.943801    192.168.1.35    192.168.1.130   HTTP    GET /mnt/vbox/workspace/WebStartSample/distC/SampleJavaLibrary.jar HTTP/1.1 
  18  0.991748    192.168.1.130   192.168.1.35    HTTP    HTTP/1.1 404 Not Found  (text/html)
  22  0.997281    192.168.1.35    192.168.1.130   HTTP    GET /mnt/vbox/workspace/WebStartSample/distC/SampleJavaLibrary.jar HTTP/1.1 
  24  1.004799    192.168.1.130   192.168.1.35    HTTP    HTTP/1.1 404 Not Found  (text/html)
  </code></pre>
  
  <p>Ultimately, after above retrying, the class is being found and initialized (!), most likely from the already existing jar, which was loaded at application startup.</p>
  
  <p>Why is jnlp class loader looking into base folder, and why for so many retries, is beyond me. I did tried to run under debugger, but could not find the sources for class loaders and could not figure it myself.</p>
  
  <p>FWIW here is my jnlp file, and yes, I did tried all variations of update tag, lazy, eager, no changes</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;jnlp codebase="http://mydebian.mydomain/mnt/vbox/workspace/WebStartSample/distC"    href="launch.jnlp" spec="1.0+"&gt;
      &lt;information&gt;
          &lt;title&gt;WebStartSample&lt;/title&gt;
          &lt;vendor&gt;user&lt;/vendor&gt;
          &lt;homepage href=""/&gt;
          &lt;description&gt;WebStartSample&lt;/description&gt;
          &lt;description kind="short"&gt;WebStartSample&lt;/description&gt;
  
      &lt;/information&gt;
  &lt;update check="always"/&gt;
  
      &lt;resources&gt;
  &lt;j2se version="1.5+"/&gt;
  &lt;jar href="WebStartSample.jar" main="true"/&gt;
  
  
      &lt;jar href="lib/SampleJavaLibrary.jar"/&gt;
  &lt;/resources&gt;
      &lt;application-desc main-class="webstartsample.Main"&gt;
  
      &lt;/application-desc&gt;
  &lt;/jnlp&gt;
  </code></pre>
  
  <p>I suspect there is something wrong with the JNLPClassLoader(), that is the particular loader used within the webstart.</p>
  
  <p>Regards,</p>
  
  <p>Robert</p>