The Source for Java Technology Collaboration

Home » java.net Forums » Java Deployment & Distribution » Java Plug-in

Thread: Launching Applets Through JNLP Link Has Got to Be Easier Than This.

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 10 - Last Post: May 30, 2009 2:39 AM by: evgeni_sergeev Threads: [ Previous | Next ]
mikeazzi

Posts: 43
Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jun 26, 2008 2:58 PM
  Click to reply to this thread Reply

Maybe I don't know what I am doing, maybe I am stupid, but for goodness sake I have so far spent almost a half a day trying to deploy one stupid little applet using the JNLP support, and I still can't. No matter what I try or where i place the files, all I get is this exception (honestly better, more explanatory error messages could really help here):


exception: null.
java.io.FileNotFoundException: JNLP not available: testapplet.jnlp
at sun.plugin2.applet.JNLP2Manager.loadJarFiles(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.io.FileNotFoundException: JNLP not available: testapplet.jnlp

I am using three simple files in my experiment: testapplet.html, testapplet.jnlp, and AppletTest.jar. The applet tag in the html looks like this:

<APPLET width=350 height=200 archive="AppletTest.jar">
<param name="jnlp_href" value="testapplet.jnlp">
</APPLET>

the testapplet.jnlp looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp href="test.testapplet">
<information>
<title>Applet HTML Page</title>
<vendor>My Company, Inc</vendor>
<offline-allowed/>
</information>
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se">
<jar href="AppletTest.jar">
</resources>
<applet-desc
name="test.TestApplet"
main-class="test.TestApplet"
width="300"
height="300">
</applet-desc>
</jnlp>

I would really appreciate it if someone could tell me what am I doing wrong. I am using b26 on Win XP and FF3/IE6.

Thanks.

andrewherron

Posts: 51
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jun 26, 2008 9:26 PM   in response to: mikeazzi
  Click to reply to this thread Reply

In the Java control panel, under debugging on the advanced tab ensure both logging and tracing are checked.

The next time you start Java, the console should tell you what HTTP connections it attempts to make to download the applet. My guess is it's looking in the wrong place for the jar file.

mikeazzi

Posts: 43
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jun 30, 2008 11:38 AM   in response to: andrewherron
  Click to reply to this thread Reply

Thanks Andrew for the tip. I tried what you suggested, and here's what I got in the console for error messages:

network: Cache entry found [url: http://localhost:8081/test/testapplet.jnlp, version: null]
network: Connecting http://localhost:8081/test/testapplet.jnlp with proxy=DIRECT
network: Connecting http://localhost:8081/ with proxy=DIRECT
network: ResponseCode for http://localhost:8081/test/testapplet.jnlp : 304
network: Encoding for http://localhost:8081/test/testapplet.jnlp : null
network: Disconnect connection to http://localhost:8081/test/testapplet.jnlp
temp: new XMLParser with source:
temp: <?xml version="1.0" encoding="UTF-8"?>
<jnlp href="test.testapplet">
<information>
<title>Applet HTML Page</title>
<vendor>My Company, Inc</vendor>
<offline-allowed/>
</information>
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se">
<jar href="AppletTest.jar">
</resources>
<applet-desc
name="test.TestApplet"
main-class="test.TestApplet"
width="300"
height="300">
</applet-desc>
</jnlp>

temp:

returning ROOT as follows:

<jnlp href="test.testapplet">
<information>
<title>Applet HTML Page</title>
<vendor>My Company, Inc</vendor>
<offline-allowed/>
</information>
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se">
<jar href="AppletTest.jar"/>
<applet-desc name="test.TestApplet" main-class="test.TestApplet" width="300" height="300"/>
</j2se>jnlp
</resources>
</jnlp>
basic: JNLP2Manager.initialize(): JNLP not available: testapplet.jnlp
basic: exception: null.
exception: null.
java.io.FileNotFoundException: JNLP not available: testapplet.jnlp
at sun.plugin2.applet.JNLP2Manager.loadJarFiles(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.io.FileNotFoundException: JNLP not available: testapplet.jnlp

I don't know about you, but to me these error messages are not really that much help as they are still suggesting a file not found problem, which in turn kept leading to look for the wrong reason all this time. But the real cause of the problem turned out that the XML in the jnlp file was malformed. How did I find that out you ask? I changed the file extension from .jnlp to .xml and loaded it in the browser: I got the following error:

End tag 'resources' does not match the start tag 'jar'. Error processing resource 'file:///C:/apache-tomcat-6.0.16/webapps/...

</resources>
--------------^

The point that I am trying to make here is that the error messages in the applet plugin console are really misleading, unintuitive, and unhelpful. How hard is it really to tell the user that there is a xml tag parsing error in the jnlp file rather than this confusing FileNotFoundException.

Thanks.

andrewherron

Posts: 51
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jun 30, 2008 7:19 PM   in response to: mikeazzi
  Click to reply to this thread Reply

From a technical point of view I can kind of understand why it would give a FileNotFound for "JNLP not available" instead of a parsing error, but you're right. Definitely log that one as a bug, the error message is crap.

jim_weaver

Posts: 37
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jul 2, 2008 11:25 AM   in response to: andrewherron
  Click to reply to this thread Reply

hehe. I ran into that same symptom with the same error message yesterday. I would have never found the problem had I not Googled and found this thread. Thanks for having this problem and pursuing a resolution, Mike! And thanks for helping with the resolution, Andrew!

Jim Weaver

mikeazzi

Posts: 43
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jul 2, 2008 12:57 PM   in response to: jim_weaver
  Click to reply to this thread Reply

No problem Jim. I see two problems here. First is the lousy, and ambiguous error messages from the new plugin. I really wish somebody would do something about them before FCS release. And quite honestly I really don't care whether these confusing error messages make sense technically speaking or not. This is not a philosophical exercise here, this is all about common sense and what makes the developer life a little easier.
Second, I don't know whether you are using the netbeans JavaFX plugin to generate your.jnlp file or not. But that's where the second problem is. The netbeans jnlp generator produces invalid xml for the .jnlp that it generates.

So Jim, can I ask you a favor. Would you mind filing bugs for these issues where you think it's necessary. I think you have a lot more experience at this than I do. That would be really great.

Thanks.

cowwoc

Posts: 1,055
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jul 3, 2008 1:40 PM   in response to: mikeazzi
  Click to reply to this thread Reply

Hear Hear! I second that motion :) Update 10 is coming along great, but it's still got way too many rough edges to be labeled a release candidate.

rogyeu

Posts: 184
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jul 7, 2008 5:32 PM   in response to: mikeazzi
  Click to reply to this thread Reply

Hi Mike,

Thanks for reporting the issue. I have opened a CR to keep track of this issue. The bug ID is 6723296. It may take a day or 2 to show up in external bug DB.

Thanks,
RY

kbr

Posts: 251
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jul 7, 2008 6:35 PM   in response to: mikeazzi
  Click to reply to this thread Reply

Sorry for the difficulty you've had. I agree that the error reporting in this area must be significantly improved. This is being tracked under 6722585 (I closed 6723296 as a duplicate of this one). It is marked as high priority and the fix is targeted at 6u10.

mikeazzi

Posts: 43
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: Jul 8, 2008 9:23 AM   in response to: kbr
  Click to reply to this thread Reply

> Sorry for the difficulty you've had. I agree that the
> error reporting in this area must be significantly
> improved. This is being tracked under 6722585 (I
> closed 6723296 as a duplicate of this one). It is
> marked as high priority and the fix is targeted at
> 6u10.

Thanks Ken. That sounds great.

evgeni_sergeev

Posts: 1
Re: Launching Applets Through JNLP Link Has Got to Be Easier Than This.
Posted: May 30, 2009 2:39 AM   in response to: mikeazzi
  Click to reply to this thread Reply

I have just ran over a similar issue. Not sure if it's exactly the same, but here is the solution.

Apache, I think, serves the JNLP file as XML (try navigate to the JNLP file using Firefox - you'll see XML). This seems to confuse the JNLP loader - maybe it checks the mime type? I haven't looked thoroughly.

I needed a way to force Apache to send it as a application/x-java-jnlp-file
Using .htaccess didn't work for some reason.

But this PHP file worked:
<?php
$file = './Applet17_browser.jnlp';
header('Content-Description: File Transfer');
header('Content-Type: application/x-java-jnlp-file');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename="Applet17_browser.jnlp"');
readfile($file);
?>

In the HTML file generated by NetBeans, the jnlp_href parameter should be explicitly specified and pointed to the PHP file:
<script>
javafx(
{
archive: "Applet17.jar",
draggable: true,
width: 640,
height: 480,
code: "applet17.Main",
name: "Applet17", //Comma here
jnlp_href: "Applet17_browser.php"
}
);
</script>

Then it works. Otherwise in the console it would say "FileNotFoundException: JNLP not available: ...".

Evgeni

---
http://www.csse.uwa.edu.au/~sergee01/ether/




 XML java.net RSS