开发者

connection refused exception when trying to run a jar via web start

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.actio开发者_如何学运维nDownload(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"/>
    <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?


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.


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!


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜