【问题标题】:Java WebStart unable to load resource in serverJava WebStart 无法在服务器中加载资源
【发布时间】:2016-05-03 21:32:56
【问题描述】:

我想用 webstart 启动我的应用程序,netbeans 会创建“dist”文件夹,如果我从我的计算机运行 HTML,程序可以正常工作,但如果我上传 HTML、JNLP、JAR 和 lib 文件夹我服务器中的 jars 库程序抛出错误,我猜 jar 试图在 lib 文件夹中查找依赖项,但是路径中的斜杠有问题,因为服务器在 linux 上运行,这是错误:

ExitException[3]com.sun.deploy.net.FailedDownloadException:无法加载资源:http://www.abaxomol.com/dist/lib\commons-io-2.4.jar

问题不在 JNLP 中,因为我在资源标签中这样声明我的资源:

<jar href="http://www.abaxomol.com/dist/lib/commons-io-2.4.jar" size="185140" download="eager" />

在“project.properties”中我找到了这个

${file.reference.commons-io-2.4.jar}:\

我认为这是问题所在,但我不确定,知道发生了什么吗?

编辑:完整的 JNLP

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="ContenedoresChart.jnlp">
  <information>
    <title>ContenedoresChart</title>
    <vendor>Diego</vendor>
    <description>null</description>
    <offline-allowed/>
  </information>
  <resources>
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="ContenedoresChart.jar" size="2200844" download="eager" />
    <jar href="http://www.abaxomol.com/dist/lib/commons-io-2.4.jar" size="198396" download="eager" />
    <jar href="http://www.abaxomol.com/dist/lib/guava-18.0.jar" size="2410298" download="eager" />
    <jar href="http://www.abaxomol.com/dist/lib/json-simple-1.1.1.jar" size="26301" download="eager" />
  </resources>
<security>
  <all-permissions/>
</security>
  <applet-desc  width="800" height="600" main-class="com.javafx.main.NoJavaFXFallback"  name="ContenedoresChart" >
    <param name="requiredFXVersion" value="8.0+"/>
  </applet-desc>
  <jfx:javafx-desc  width="800" height="600" main-class="contenedoreschart.ContenedoresChart"  name="ContenedoresChart" />
  <update check="always"/>
</jnlp>

完整的 project.properties:

annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=ContenedoresChart
application.vendor=Diego
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
compile.on.save=true
compile.on.save.unsupported.javafx=true
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
    ${run.classpath}
debug.test.classpath=\
    ${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/ContenedoresChart.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.commons-io-2.4.jar=src\\contenedoreschart\\commons-io-2.4.jar
file.reference.guava-18.0.jar=src\\contenedoreschart\\guava-18.0.jar
file.reference.json-simple-1.1.1.jar=src\\contenedoreschart\\json-simple-1.1.1.jar
includes=**
# Non-JavaFX jar file creation is deactivated in JavaFX 2.0+ projects
jar.archive.disabled=true
jar.compress=false
javac.classpath=\
    ${javafx.classpath.extension}:\
    ${file.reference.commons-io-2.4.jar}:\
    ${file.reference.guava-18.0.jar}:\
    ${file.reference.json-simple-1.1.1.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
    ${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
    ${javac.classpath}:\
    ${build.classes.dir}
javac.test.processorpath=\
    ${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
javafx.application.implementation.version=1.0
javafx.binarycss=false
javafx.classpath.extension=\
    ${java.home}/lib/javaws.jar:\
    ${java.home}/lib/deploy.jar:\
    ${java.home}/lib/plugin.jar
javafx.deploy.adddesktopshortcut=false
javafx.deploy.addstartmenushortcut=false
javafx.deploy.allowoffline=true
# If true, application update mode is set to 'background', if false, update mode is set to 'eager'
javafx.deploy.backgroundupdate=false
javafx.deploy.disable.proxy=false
javafx.deploy.embedJNLP=true
javafx.deploy.includeDT=true
javafx.deploy.installpermanently=false
javafx.deploy.permissionselevated=true
# Set true to prevent creation of temporary copy of deployment artifacts before each run (disables concurrent runs)
javafx.disable.concurrent.runs=false
# Set true to enable multiple concurrent runs of the same WebStart or Run-in-Browser project
javafx.enable.concurrent.external.runs=false
# This is a JavaFX project
javafx.enabled=true
javafx.fallback.class=com.javafx.main.NoJavaFXFallback
# Main class for JavaFX
javafx.main.class=contenedoreschart.ContenedoresChart
javafx.preloader.class=
# This project does not use Preloader
javafx.preloader.enabled=false
javafx.preloader.jar.filename=
javafx.preloader.jar.path=
javafx.preloader.project.path=
javafx.preloader.type=none
# Set true for GlassFish only. Rebases manifest classpaths of JARs in lib dir. Not usable with signed JARs.
javafx.rebase.libs=false
javafx.run.height=600
javafx.run.width=800
javafx.signing.blob=false
javafx.signing.enabled=true
javafx.signing.type=self
# Pre-JavaFX 2.0 WebStart is deactivated in JavaFX 2.0+ projects
jnlp.enabled=false
# Main class for Java launcher
main.class=com.javafx.main.Main
# For improved security specify narrower Codebase manifest attribute to prevent RIAs from being repurposed
manifest.custom.codebase=*
# Specify Permissions manifest attribute to override default (choices: sandbox, all-permissions)
manifest.custom.permissions=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
native.bundling.enabled=false
platform.active=default_platform
run.classpath=\
    ${dist.jar}:\
    ${javac.classpath}:\
    ${build.classes.dir}
run.test.classpath=\
    ${javac.test.classpath}:\
    ${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test

【问题讨论】:

  • 我从未见过在 jar 标记中指定绝对 url。这甚至允许吗?
  • 这不是绝对的,我将其更改为绝对,因为我认为 JNLP 是问题所在,它确实适用于绝对 URL。
  • 你不应该那样做。 jar 必须是类路径的一部分。 codebase 标记用于 url。你能发布完整的 jnlp 吗?
  • 我添加了完整的 JNLP
  • 我建议只引用 lib/commons-io-2.4.jar 并检查它是否在正确的路径中。 ContenedoresChart.jar 显然已加载,因此 lib 文件夹必须与服务器上的该 jar 文件位于同一路径。

标签: java javafx jar classpath java-web-start


【解决方案1】:

尝试从 Java 控制面板中删除 Java 缓存。

【讨论】:

    【解决方案2】:

    我不得不手动将生成的 HTML 和 JNLP 中的所有内容复制到新文件中,将这些文件上传到服务器并删除旧文件,并且由于某种原因它起作用了。也许是一个错误?我不知道。

    【讨论】:

    • 手动复制内容是什么意思?它有什么不同?
    • 我的意思是把两个窗口并排放置,然后逐个字符地将原来的内容复制到一个新的文件中。我不知道它为什么会起作用,当我用 Janela 扫描原始文件时,它显示了一个错误,其中包含不可见的字符,可能在自动生成的 JNLP 中有一些不可见的字符,并且通过手动复制隐藏的字符不在文件了,这是我最好的猜测。
    猜你喜欢
    • 2012-09-14
    • 1970-01-01
    • 1970-01-01
    • 2014-05-22
    • 2020-01-11
    • 2019-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多