Java WebStart slow, requesting libraries from invalid folder

后端 未结 3 1463
走了就别回头了
走了就别回头了 2020-12-21 10:26

Problem and question: Java webstarted app looking for its classes in base folder instead of ./lib.

As suggested in similar question at Java Web Start applications a

相关标签:
3条回答
  • 2020-12-21 11:02

    Thanks everyone for suggestions. It was Andrew hint to 'index the jars' which pointed me to the right direction...

    Namely, the jars (produced my current IDE of choice, Netbeans) were indexed. However, the META-INF/INDEX.LIST within the main jar contained the references to other jars as if they were in current folder, next to the main jar.

    JarIndex-Version: 1.0
    
    WebStartSample.jar
    webstartsample
    
    SampleJavaLibrary.jar
    newpackage
    

    That resulted in jnlpClassLoader(), using the main index, and looking for jars in codebase url, while they actually resided under ./lib url subfolder.

    This is how the correct index (recreated manually) looks:

    JarIndex-Version: 1.0
    
    WebStartSample.jar
    webstartsample
    
    lib/SampleJavaLibrary.jar
    newpackage
    

    To make the problem worst, such webstarted application would not fail, they would just look for classes/jars in wrong places first, and then eventually find them, presumably already loaded bu jnlp loader as described in original question.

    Briefly, this IS related to Netbeans build and packaging procedure.

    My immediate fix was disabling the jar indexing, and that resulted in correct and minimal network traffic, and greatly improved application initialization.

    To do it in Netbeans, go to Tools->Options->Miscellaneous->Ant->Properties and add jar.index=false

    Proper fix would be to make Netbeans index the jar correctly but that is the another question.

    Again, thanks all for suggestions.

    ps.

    • janela util found no major faults in my jnlp
    • package element including made no changes
    • mydebian refers to my server, the client is win7 with all latest and greatest java runtimes and jdks, including netbeans 6.9 (also tested with 7.0, same problematic index produced)
    0 讨论(0)
  • 2020-12-21 11:04

    The "mydebian.mydomain" hostname hints you are running on Debian, where OpenJDK is the default Java implementation.

    The Sun Java WebStart implementation is not part of OpenJDK, so an alternative implementation is used. As Java WebStart does not have an official TCK there are subtle differences and even bugs in the OpenJDK implementation which needs to be found manually (as there is no official TCK).

    I would suggest trying with a Sun JVM (e.g. on Windows) and see if the behaviour changes.

    0 讨论(0)
  • 2020-12-21 11:18

    Recommendations:

    1. Validate the JNLP using JaNeLA. It seems valid to my eye, but JaNeLA is the better judge.
    2. Include the package element for each Jar. This element is mentioned in the Resources section of the JNLP File Syntax (also expanded in the table at the top of the page). Chase the link in the page to the (downloadable only) API Specification for further details of the package element. And as an aside, the API Spec. is the single best resource on JWS. I wish Oracle would make it web-browsable.
    3. Index the Jar files.
    4. Continue to ask such great (well thought out, well researched, well presented) questions. :)
    0 讨论(0)
提交回复
热议问题