Java WebStart slow, requesting libraries from invalid folder

后端 未结 3 1469
走了就别回头了
走了就别回头了 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条回答
  •  萌比男神i
    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)

提交回复
热议问题