2

I've run into a problem when trying to launch a jar file using JNLP. We've previously launched the applet without JNLP without any problems. We want to launch three different jars who are kept in the same directory together with the jnlp file. All jars are downloaded but we see a classNotFoundError as soon as we try to load a class from one of the external jars (i.e the ones that aren't the main one). The application runs until this happens so our main jar seem to execute. The JNLP file looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" href="/jars/file.jnlp">
<information>
    <title>Client</title>
    <vendor>My Vendor</vendor>
    <description>Description</description>
    <description kind="short">Desc</description>
    <offline-allowed />
</information>
<security>
    <all-permissions />
</security>

<resources>
    <j2se version="1.6+" />
    <jar href="mainJar.jar" main="true" download="eager"/>
    <jar href="extJar1.jar" main="false" download="eager"/>
    <jar href="extJar2.jar" main="false" download="eager" />
</resources>
<applet-desc 
    name="MyApp" 
    main-class="path-to-main-class"
    width="1"
    height="1">
</applet-desc>
</jnlp>

The applet is then launched from the HTML file like this:

<applet
    code="com.mycompany.net.MyMainClass" 
    name="MyApp" 
    archive="/jars/extJar1.jar, /jars/extJar2.jar, /jars/mainJar.jar" 
    id="myId" 
    width="1" 
    height="1" 
    mayscript
    alt="The java plugin must be installed.">
            <param name="jnlp_href" value="/jars/file.jnlp"/>
    Java 1.5 or higher required.  
</applet>

I've checked then jnlp with Janela which gives me no errors. It works to run the applet from Eclipse as well as without the jnlp file. It also works to open the jnlp-file from javaws, specifying either the file or the url to the file. That leads me to think it's the html that is incorrect. This is however as far as I got. I've tried launching with the following javascript with same result:

<script src="http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
        id:'myId', 
  code:'com.mycompany.net.MyMainClass', 
  width:1, 
  height:1, 
  name:"MyApp"
};
    var parameters = {
        jnlp_href:"/jars/file.jnlp",
        archive:"/jars/extJar1.jar, /jars/extJar2.jar, /jars/mainJar.jar",
    };
deployJava.runApplet(attributes, parameters, '1.6');

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Erik
  • 663
  • 2
  • 7
  • 10
  • I cans see nothing wrong with either the JNLP (good call on using JaNeLA) or applet/JS element. What browser(s) are you testing in? – Andrew Thompson Apr 19 '12 at 22:33
  • Chrome and Firefox. I think I found my root cause. Once the jars are all downloaded the server gets a new request asking for the class that later is not found. But why does it look for the class file in my jar folder and not in the jar? – Erik Apr 20 '12 at 14:31
  • [Codebase](http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/applet/codebase_determination.html) param in the jnlp tag? That was in my answer anyway. – Fuhrmanator Apr 20 '12 at 15:14
  • I managed to get it working by returning a 404 instead of a redirect when it tries to find the class file at the server. I have no idea why it goes to the server at all for the class files though but that is the next step to figure out. At least it works now.. – Erik Apr 20 '12 at 15:34
  • **@Erik** [Example 4](http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/applet/codebase_determination.html#CODEBASE_EXAMPLES) seems close to your situation, although you didn't specify the path of your example HTML file. If it's not in the /jars/ folder, then the implicit codebase will point to the same dir as your HTML file. – Fuhrmanator Apr 20 '12 at 15:56
  • @Fuhrmanator My jar files are located in the same folder as my jnlp file so it should default to the correct folder. What I don't understand is why it looks to the server for my class files instead of first looking in the jars. As it is now it tries to access /jars/org/company/../.class instead of /jars/extJar1/org/company/../.class. – Erik Apr 20 '12 at 16:28
  • @Erik where is the HTML file in that access path you gave? – Fuhrmanator Apr 20 '12 at 17:28

1 Answers1

0

My JNLPs use external jars, and I defined the codebase="http://example.com/full/path/to/jars/" as well as href="http://example.com/full/path/to/jars/file.jnlp" in the <jnlp> tag.

Edit Try my working example - click the Lancer le planificateur button to see it in action.

edit2 check out JNLP as a Applet in HTML page to see if Object rather than Applet will help.

Community
  • 1
  • 1
Fuhrmanator
  • 11,459
  • 6
  • 62
  • 111