tags:

views:

90

answers:

5

I am getting the following exception when trying to run my jar through java web start:

com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://localhost   /ValidatorWEB/validator.jnlp
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)

This is the wrapped exception:

java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)

Here is my .jnlp file:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://localhost/ValidatorWEB/" 
href="validator.jnlp">
<information>
    <title>Validator</title>
    <vendor>My Company</vendor>
</information>
<resources>
    <!-- Application Resources -->
    <j2se version="1.6+"
          href="http://java.sun.com/products/autodl/j2se"/&gt;
    <jar href="WEB-INF/lib/validator.jar" main="true" />

</resources>
<application-desc
     name="Validator"
     main-class="webstartComponentArch.DynamicTreeApplication"
     width="300"
     height="300">
 </application-desc>
 <update check="background"/>

I am deploying the whole thing as a simple WAR to glassfish v2.1 on my local machine. The validator.jar is located in WEB-INF/lib and the jnlp and jsp page I am accessing the jnlp from is at the root of the ValidatorWEB folder.

Googling hasn't helped. I have tried turning my firewall off and it still does the same thing. I have the appropriate Mime-type set in Glassfish. Is there something else I'm forgetting to do?

A: 

How about the policy file? See here: http://blogs.sun.com/monzillo/entry/policy_files_the_securitymanager_and

nfechner
I'm not familiar with that at all. I did a quick google on it, but didn't find anything that references policies and web start. Can you be a bit more specific as to what I should verify is there or not?
Casey
Look for this file:$J2EE_HOME/domains/domainx/config/server.policyand set its content togrant { permission java.security.AllPermission;}This is just for testing!! If this helps, you're on the right track and should read the link in my original post and this one: http://java.sun.com/j2se/1.4.2/docs/guide/security/PolicyFiles.html
nfechner
A: 

You do know what http://localhost actually points to? It points to the web server which is running at localhost at port 80. Localhost == 127.0.0.1 == local machine.

As Webstart aka JNLP apps runs at the client machine, it will try to connect the web server at the same (local) machine. You don't want to do that. Change the URL to point to the actual web server at the server machine where your webapp runs and where JNLP is to be downloaded from.

BalusC
I am trying to run it from localhost. I am not currently deploying to a seperate machine.
Casey
A: 

The spaces after localhost make me suspicious - is there a chance you've defined the hostname with trailing spaces somewhere and web start isn't having any of it?

Also, have you tried simply wgetting (or similar) the listed jnlp URL? The response from the request will let you see what's happening when Java makes the same request.

Andrzej Doyle
There aren't any spaces after localhost. Not that I see in the editor.
Casey
Spaces look like an artifact of the terminal line wrapping to me.
Tom Hawtin - tackline
A: 

I dont know if its related but while giving address of resource jar, i would not use "WEB-ıNF/lib", client machine cannot see inside web-inf, you should put that jar inside web application not inside web-inf.

erdemoo
That wasn't the problem, but I did have to move the validator.jar to the same place as my .jnlp file. I couldn't get it to access the resource correctly while it was in the WEB-INF/lib folder.
Casey
A: 

So I figured it out. The problem was where I am specifying the base url:

<jnlp spec="1.0+" codebase="http://localhost/ValidatorWEB/" href="validator.jnlp">

When I deployed to Glassfish, the url that I would access the web application through is actually:

http://localhost:8080/ValidatorWEB/

I had to change my codebase to read:

<jnlp spec="1.0+" codebase="http://localhost:8080/ValidatorWEB/" href="validator.jnlp">

This is something I will definitely have to keep in mind when deploying to a remote server.

Thanks for all of the input!

Casey
I believe there is a servlet thing from Sun that can generate the correct JNLP for a given deployment.
Thorbjørn Ravn Andersen
Yes, I am using that now.
Casey