【问题标题】:Netbeans JNLP Webstart errorNetbeans JNLP Webstart 错误
【发布时间】:2015-03-23 00:38:55
【问题描述】:

我整天都在与这个作斗争,我根本无法弄清楚我做错了什么。我在 netbeans 中有一个项目,根据 netbeans 教程中的方法,我为其创建了一个 Web 起始页,但是每次我尝试将教程项目或我的项目作为 Web 启动运行时,我都会收到以下错误:

java.lang.NumberFormatException: For input string: "\Users\<snip>"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebase(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(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.access$000(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

我的 jnlp 文件是:

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/Users/<snip>/dist/" href="launch.jnlp" spec="1.0+">
    <information>
        <title>...</title>
        <vendor>me</vendor>
        <homepage href=""/>
        <description>...</description>
        <description kind="short">...</description>
    </information>
    <update check="background"/>
    <security>
<all-permissions/>
</security>
    <resources>
    <j2se version="1.8+"/>
    <jar eagar="true" href="<snip>.jar" main="true"/>

    </resources>
    <application-desc main-class="<snip>">
    </application-desc>
    </jnlp>

非常感谢您对此的帮助

【问题讨论】:

  • 请务必使用 JaNeLA 检查 JNLP,可通过我的share drive 获取。
  • 出于某种原因,我认为它试图将我的路径设置为 intiger
  • @user2352274 尝试删除代码库部分,它现在是可选的并升级您的规范版本。例如:&lt;jnlp href="launch.jnlp" spec="7.0+"&gt;
  • 感谢您的评论,我试了一下,但仍然遇到同样的错误
  • @user2352274 这只能意味着以下两件事之一:(1)您没有运行您认为正在运行的程序(如果您完全删除了 jnlp 中对 C:/Users 的引用,您可以'没有得到引用它的错误) - 这可能是由于缓存或(2)问题出在你的 jnlp 中的某个地方,你没有显示......

标签: java java-web-start jnlp


【解决方案1】:

只需将您的 jnlp 更改为:

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/MyFolder/" href="launch.jnlp" spec="1.0+">
    <information>
        <title>...</title>
        <vendor>me</vendor>
        <homepage href=""/>
        <description>...</description>
        <description kind="short">...</description>
    </information>
    <update check="background"/>
    <security>
<all-permissions/>
</security>
    <resources>
    <j2se version="1.8+"/>
    <jar eagar="true" href="MyJarFile.jar" main="true"/>

    </resources>
    <application-desc main-class="com.MyCompany.MyMainClass">
    </application-desc>
    </jnlp>

编辑:如果这没有帮助或您对此有疑问,请在下方添加您的评论。

【讨论】:

  • 当我尝试你的代码时,我得到了完全相同的错误,这非常令人困惑,因为我可以完美地运行 jar,我只需通过不通过 jnlp 来打开它
  • 我确定我的代码中的错误与您的不同。您的代码有这个错误:java.lang.NumberFormatException:对于输入字符串:“\Users\”。但是我的代码中没有 。所以再次尝试我的代码,让我确切地知道你得到了什么错误。还要注意,无论我把“我的...”放在哪里,你都应该用你的文件名替换它。例如,将 MyJarFile.jar 更改为 jar 文件的实际名称。
【解决方案2】:

试试

file:///C:/Users/snip/dist/

在您的 JNLP-XML 代码库中。
文件 Uri-Scheme 需要 2x // (file://)

编辑
对此没有意见?

因此,如果这不起作用,您可以尝试以下操作:
https://stackoverflow.com/a/2417010/3887073

告诉我们:

<jnlp spec="1.0+" codebase="file://localhost/X:/path/to/jnlp/" href="software.jnlp">

【讨论】:

  • 很抱歉缺少 cmets,这仍然会引发我完全困惑的相同错误。
【解决方案3】:

确保您没有在代码中的任何位置使用应用程序的路径作为值。如果程序接受命令行参数,请尝试在 JNLP 文件中将参数指定为 &lt;application-desc&gt;&lt;argument&gt;&lt;/argument&gt; 子元素,并直接从命令行运行 Java Web Start 程序

javaws path.to.ClassWithMainMethod

【讨论】:

    【解决方案4】:

    您似乎在 webstart 应用程序中从用户那里获取某种输入。

    java.lang.NumberFormatException: For input string: "\Users\<snip>"
    at java.lang.NumberFormatException.forInputString(Unknown Source)
    

    从这一行来看,您要求用户输入一个整数,然后他们输入一个字符串或其他东西。

    如果您不接受任何用户输入,重新安装 NetBeans 可能会有所帮助。

    干杯。

    【讨论】:

    • 我在代码中的某处将日期转换为字符串,但如果我打开 jar 文件,我的应用程序运行没有任何问题。所以这很奇怪。 (而且很烦人)
    • 实际上,查看堆栈跟踪,可以注意到错误发生在 com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx 中,它负责验证应用程序的签名。他的代码甚至还没有被调用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-24
    • 1970-01-01
    • 2011-11-16
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    相关资源
    最近更新 更多