JWS堆栈溢出错误

时间:2012-02-13 02:14:45

标签: java java-web-start

我喜欢使用Java Web Start将我的Java游戏演示到网上,以便用户可以查看游戏角色等等。

我使用Eclipse export runnable jar功能将项目导出到jar文件。然后我成功地使用java -jar运行它。我设置了test.jnlp文件,如下所示:

    <?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="/home/bili/JWSdeploytest/" href="test.jnlp">
  <information>
    <title>Demo</title>
    <vendor>binman</vendor>
    <description>Test</description>
    <offline-allowed/>
  </information>
  <resources>
    <jar href="LoadbonesFOrmat.jar" main="true"/>
    <extension name="Demo" href="test.jnlp" />
  </resources>
  <security>
    <all-permissions/>
  </security>
  <application-desc />
</jnlp>

我尝试在我的机器上本地测试它,并启用调试打开,我在这里阅读其他文章:

set JAVAWS_TRACE_NATIVE=1
set JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket, address=8989,server=y,suspend=n"

但是当我跑javaws test.jnlp时,我得到了StackOverflowError。以下是输出:

bili@bili-SFF:~/JWSdeploytest$ javaws -J test.jnlp 
Exception in thread "Demo" java.lang.StackOverflowError
    at java.util.LinkedHashMap$LinkedHashIterator.<init>(LinkedHashMap.java:362)
    at java.util.LinkedHashMap$LinkedHashIterator.<init>(LinkedHashMap.java:362)
    at java.util.LinkedHashMap$KeyIterator.<init>(LinkedHashMap.java:400)
    at java.util.LinkedHashMap$KeyIterator.<init>(LinkedHashMap.java:400)
    at java.util.LinkedHashMap.newKeyIterator(LinkedHashMap.java:413)
    at java.util.HashMap$KeySet.iterator(HashMap.java:891)
    at java.io.ExpiringCache.cleanup(ExpiringCache.java:117)
    at java.io.ExpiringCache.get(ExpiringCache.java:74)
    at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:152)
    at java.io.File.getCanonicalPath(File.java:576)
    at sun.security.provider.PolicyFile.canonPath(PolicyFile.java:1872)
    at java.io.FilePermission$1.run(FilePermission.java:203)
    at java.io.FilePermission$1.run(FilePermission.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.io.FilePermission.init(FilePermission.java:200)
    at java.io.FilePermission.<init>(FilePermission.java:266)
    at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
    at net.sourceforge.jnlp.config.DeploymentConfiguration.getProperty(DeploymentConfiguration.java:269)
    at net.sourceforge.jnlp.SecurityDesc.getCustomTrustedPolicy(SecurityDesc.java:172)
    at net.sourceforge.jnlp.SecurityDesc.<init>(SecurityDesc.java:159)
    at net.sourceforge.jnlp.Parser.getSecurity(Parser.java:553)
    at net.sourceforge.jnlp.JNLPFile.parse(JNLPFile.java:594)
    at net.sourceforge.jnlp.JNLPFile.<init>(JNLPFile.java:178)
    at net.sourceforge.jnlp.JNLPFile.<init>(JNLPFile.java:211)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:351)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.initializeExtensions(JNLPClassLoader.java:370)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.<init>(JNLPClassLoader.java:174)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:295)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:351)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.initializeExtensions(JNLPClassLoader.java:370)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.<init>(JNLPClassLoader.java:174)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:295)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:351)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.initializeExtensions(JNLPClassLoader.java:370)

三线295:351:370重复了十几次。 它从输出中看起来好像存在一些限制访问。我检查并验证了Jar文件,jnlp是否允许执行/读取。

我开始怀疑我是否需要一个Web服务器来测试它。然而,由于我以前从未与JWS合作,因此很少有事情在我的脑海中产生怀疑:

  1. jar文件有问题(我没有正确导出)
  2. test.jnlp未正确配置
  3. 关于如何解决这个JWS业务的任何指示?

    编辑:我删除了extention元素,并抛出另一个异常:

        bili@bili-SFF:~/JWSdeploytest$ javaws test.jnlp 
    net.sourceforge.jnlp.LaunchException: Fatal: Launch Error: Could not launch JNLP file.
        at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:596)
        at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:887)
    Caused by: java.lang.IllegalArgumentException: file:/home/bili/JWSdeploytest/LoadbonesFOrmat.jar is not a cacheable resource
        at net.sourceforge.jnlp.cache.CacheUtil.getCacheFile(CacheUtil.java:297)
        at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:561)
        ... 1 more
    Caused by: 
    java.lang.IllegalArgumentException: file:/home/bili/JWSdeploytest/LoadbonesFOrmat.jar is not a cacheable resource
        at net.sourceforge.jnlp.cache.CacheUtil.getCacheFile(CacheUtil.java:297)
        at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:561)
        at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:887)
    

    这个看起来更直观,这次我很肯定我没有正确打包Jar文件。稍后再试一次。 以下是JaNeLA的输出:

    content type application/xml does not equal expected type of application/x-java-jnlp-file
    XML encoding not known, but declared as utf-8
    Codebase '/home/bili/JWSdeploytest/' is a malformed URL!  Defaulting to file:/home/bili/JWSdeploytest/test.jnlp
    Codebase '/home/bili/JWSdeploytest/' is a malformed URL!  Defaulting to file:/home/bili/JWSdeploytest/test.jnlp
    Codebase '/home/bili/JWSdeploytest/' is a malformed URL!  Defaulting to file:/home/bili/JWSdeploytest/test.jnlp
    Codebase '/home/bili/JWSdeploytest/' is a malformed URL!  Defaulting to file:/home/bili/JWSdeploytest/test.jnlp
    Downloads can be optimized by specifying a resource size for 'LoadbonesFOrmat.jar'.
    The resource download at LoadbonesFOrmat.jar can be optimized by removing the (default) value of download='eager'.
    Lazy downloads might not work as expected for LoadbonesFOrmat.jar unless the download 'part' is specified. 
    

    我已经将安全元素移到了资源元素之上,以摆脱cvc-complex-type.2.4.a:根据JaNeLa网站上的帮助文件。在控制台中,它说文档有效,但数据可能仍然是错误的!

1 个答案:

答案 0 :(得分:2)

JNLP文件有许多可疑方面。大多数特别是它是test.jnlp,但也声称要加载相同名称的扩展名!这可能是导致堆栈溢出的原因。

使用JaNeLA验证JNLP。它还将确定一些其他问题。作为JaNeLA的作者,我很想知道它是否也会抛出StackOverflowError,因为它试图验证主要的JNLP 以及任何扩展。我怀疑它会进入一个无限循环(请报告回来)。

我猜测只有一个Jar。如果是这种情况,请删除整个extension元素。

顺便说一句 - 是真正称为LoadbonesFOrmat.jar的Jar吗?这是大写字母的非常奇怪的使用,我会称之为LoadbonesFormat.jarLoadBonesFormat.jar(即没有大写O)。