Java Webstart无法脱机工作(NoRouteToHostException / UnknownHostException)

时间:2010-09-14 02:54:57

标签: java jnlp java-web-start

我想配置我的webstart应用程序/ jnlp,这样如果没有可用的Internet连接,它将从缓存开始。 尽管如此,当我断开网络连接时,我总是会收到NoRouteToHostException或UnknownHostException异常,尽管有以下配置。

我认为我已正确设置了脱机允许和更新标签/属性;我找不到webstart仍在尝试查找主机的原因。 当我连接时,我肯定有从我之前的开始缓存的应用程序。

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="6.0+" codebase="http://cms.mydomain.com/sync/" href="myAppSync.jnlp">

<information>
    <title>My App Sync</title>
    <vendor>My Company</vendor>
    <homepage href="http://www.myapp.com/"/>
    <description>Sync application for My App</description>
    <icon href="ATTico.png"/>        

    <!-- allow app to run without Internet access -->
    <offline-allowed/>

    <shortcut online="true">          
      <desktop/>
      <!-- create menu item for this app under the major heading 'My App' -->
      <menu submenu="My App"/>
    </shortcut>

</information>

<security>
    <all-permissions/>
</security>

<update check="timeout" policy="always" />

<resources>
    <java version="1.6*" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="lib/myAppSync.jar" />
    <jar href="lib/apache-mime4j-0.6.jar" />
    <jar href="lib/commons-logging-1.1.1.jar" />
    <jar href="lib/commons-codec-1.3.jar" />
    <jar href="lib/httpclient-4.0.1.jar" />
    <jar href="lib/httpcore-4.0.1.jar" />
    <jar href="lib/httpmime-4.0.1.jar" />
    <jar href="lib/swingx-1.6.jar" />
    <jar href="lib/swingx-beaninfo-1.6.jar" />        
</resources>

<application-desc main-class="com.myapp.sync.forms.Main"/>

</jnlp>

错误日志:

java.net.NoRouteToHostException: No route to host: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doGetRequestEX(Unknown Source)
at com.sun.deploy.net.DownloadEngine.isUpdateAvailable(Unknown Source)
at com.sun.deploy.net.DownloadEngine.isUpdateAvailable(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source)
at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source)
at com.sun.javaws.Launcher.downloadResources(Unknown Source)
at com.sun.javaws.Launcher.prepareLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)



java.net.UnknownHostException: cms.mydomain.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
at com.sun.deploy.net.BasicHttpRequest.doGetRequestEX(Unknown Source)
at com.sun.deploy.net.DownloadEngine.isUpdateAvailable(Unknown Source)
at com.sun.deploy.net.DownloadEngine.isUpdateAvailable(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source)
at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source)
at com.sun.javaws.Launcher.downloadResources(Unknown Source)
at com.sun.javaws.Launcher.prepareLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

2 个答案:

答案 0 :(得分:3)

我通过使用-offline参数从命令行调用javaws找到了一个解决方案,但我觉得这很奇怪,这是必要的,想知道为什么系统无法自动检测到我是否处于脱机状态,因此检查时超时从我的jnlp中定义的缓存启动应用程序。

javaws -offline myApp.jnlp

答案 1 :(得分:0)

这可以通过使用<update check="background"/>来实现,但是在可用时不再立即下载更新,它需要第二次启动,这很烦人。

这真的感觉像是一个Java Web Start错误,如果与服务器的连接超时,<update check="timeout"/>不应该阻止应用程序启动。