2
votes

I'm far from a Java expert, so please bear with me. :)

I've also Googled and read docs for three days, but this is still unclear to me, so please don't vote me down. :)

Im working on a project that is trying to deploy our application via Java Web Start. I'm able to get a "HelloWorld" app to work, but not our project. I think the problem is with the resouces tag in my jnlp file, but I'm not certain.

During my first attempts, the JNLP loader said it couldnt find the log4j lib, even though it was in the specified location. My technical lead said the problem might be that Java was actually looking for the other jar files, but only throwing the log4j error, because its the first step in the application. I added all of the jars to the resource section, and now the loader closes without giving any messages at all. (You can try it, here - http://www.powellportfolio.net/test/webstarttest/Match.jnlp )

Do I need to list every jar file in resources?

Do I also need to include tags for the classes? If so, do I need to create a jar file for them, or just link them individually? I tried jarring them, but that may be the wrong approach.

Do you know why the loader is closing without any messages?

Do you have any other suggestions?

Heres my jnlp file:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://www.powellportfolio.net/test/webstarttest/" href="Match.jnlp">
    <information>
        <title>Jnlp Testing</title>
        <vendor>My Company</vendor>
        <homepage href="http://www.powellportfolio.net/test/webstarttest/" />
        <description>Testing Testing</description>
                                <offline-allowed/>
    </information>
    <resources>
        <j2se version="1.6+" />
        <jar href="Match.jar" />
                                <jar href="Match_lib/commons-cli-1.2.jar" />
        <jar href="Match_lib/dcm4che-audit-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-base64-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-core-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-filecache-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-hp-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-image-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-imageio-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-imageio-rle-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-iod-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-net-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-soundex-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcm2dcm-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcm2jpg-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcm2txt-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcm2xml-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmdir-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmecho-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmgpwl-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmhpqr-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmmv-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmmwl-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmof-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmqr-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmrcv-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmsnd-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmups-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-dcmwado-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-fixjpegls-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-jpg2dcm-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-logger-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-pdf2dcm-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-rgb2ybr-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-txt2dcmsr-2.0.26.jar" />
        <jar href="Match_lib/dcm4che-tool-xml2dcm-2.0.26.jar" />
        <jar href="Match_lib/derby.jar" />
        <jar href="Match_lib/derbyclient.jar" />
        <jar href="Match_lib/derbyLocale_cs.jar" />
        <jar href="Match_lib/derbyLocale_de_DE.jar" />
        <jar href="Match_lib/derbyLocale_es.jar" />
        <jar href="Match_lib/derbyLocale_fr.jar" />
        <jar href="Match_lib/derbyLocale_hu.jar" />
        <jar href="Match_lib/derbyLocale_it.jar" />
        <jar href="Match_lib/derbyLocale_ja_JP.jar" />
        <jar href="Match_lib/derbyLocale_ko_KR.jar" />
        <jar href="Match_lib/derbyLocale_pl.jar" />
        <jar href="Match_lib/derbyLocale_pt_BR.jar" />
        <jar href="Match_lib/derbyLocale_ru.jar" />
        <jar href="Match_lib/derbyLocale_zh_CN.jar" />
        <jar href="Match_lib/derbyLocale_zh_TW.jar" />
        <jar href="Match_lib/derbynet.jar" />
        <jar href="Match_lib/derbyrun.jar" />
        <jar href="Match_lib/derbytools.jar" />
        <jar href="Match_lib/log4j-1.2.16.jar" />
        <jar href="Match_lib/slf4j-api-1.6.1.jar" />
        <jar href="Match_lib/slf4j-log4j12-1.6.1.jar" />
        <jar href="classes/classes.jar" />
    </resources>                
    <application-desc main-class="gui.GUIMatch" />
</jnlp>
1
You packed the Match.jar with Eclipse so it uses an Class-Loader from Eclipse and loads the needed jars (e.g. log4j) from the jar itself. Jars are zip file so you can extract the content from it with a "unarchiver". If I download the Match.jar and run it with java -jar it works. - alexvetter
"You packed the Match.jar with Eclipse..." Does this mean I don't need to include the jars in my jnlp file? I've tried exporting as a runnable jar file from Eclipse with all three options (extract libs to jar, package libs into jar, copy libs into sub-folder). I still got an error about log4j, even though I verified it was in my jar, which was what stumped me. Also, I can run the Match.jar directly, but not through Match.jnlp. How come? - user359519
Do you have a solution for this problem ? - sridhar

1 Answers

3
votes

Do I need to list every jar file in resources?

Not necessarily. Later JWS launches allow for us to specify a Jar containing the main-class & a manifest specifying the main class and all dependent Jars. OTOH I find it easier and more clear to explicitly list each Jar.

  • It declares the resources in a human readable form (if you consider the JNLP to be 'human readable').
  • It allows some Jars to be loaded lazily or programmatically. If listed in the manifest, the Jar is downloaded eagerly.

Do I also need to include tags for the classes? If so, do I need to create a jar file for them, or just link them individually?

JWS cannot deploy loose class files, they need to be in a Jar.

I tried jarring them, but that may be the wrong approach.

It is the only approach that can work. Stick with it.

Do you know why the loader is closing without any messages?

Not immediately. Validate the JNLP using JaNeLA & ensure the Java Console is configured to show on launch.