JWS堆栈溢出错误
我喜欢使用 Java Web Start 将我的 Java 游戏演示发布到网络上,以便用户可以查看游戏角色并与之交互等。
我使用 Eclipse 导出可运行 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 是否允许执行/读取。
我开始怀疑我是否需要一个网络服务器来测试它。然而,由于我以前从未使用过 JWS,所以有几件事让我产生了疑问:
- jar 文件出了问题(我没有正确导出它)
test.jnlp
未正确配置
任何指针至于如何解决这个JWS业务?
编辑:我已经删除了扩展元素,它抛出了另一个异常:
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.
根据 JaNeLa 网站上的帮助文件,我已将安全元素移至资源元素上方,以摆脱 cvc-complex-type.2.4.a:。在控制台中,它说文档有效,但数据可能仍然是错误的!
I like to use Java Web Start to put up a demo of my Java game to the web so that user can view and interact with the game characters and so on.
I exported the project to a jar file using Eclipse export runnable jar feature. I was then able to run it with java -jar
successfully. I set up a test.jnlp
file as below:
<?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>
I tried to test it locally on my machine with debug turning on that I read from other post on here:
set JAVAWS_TRACE_NATIVE=1
set JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket, address=8989,server=y,suspend=n"
But when I run javaws test.jnlp
I got StackOverflowError
. Below is output:
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)
The three line 295:351:370 are repeated dozen more time.
It looks to me from the output as if there is some restricted access going on. I checked and verified that the Jar file, jnlp are allowed to be executed/read.
I start to wonder if I need a web server to test it out. However few things that cast doubt in my mind as I never work with JWS before:
- Something is wrong with the jar file (I didn't export it correctly)
- The
test.jnlp
is not configured correctly
Any pointers as to how can I solve this JWS business?
Edit: I have removed the extention element and it throws another Exception:
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)
This one seems more intuitive and I'm positive this timethat I haven't packed the Jar file correctly. Going to try it again later.
Here is the output from 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.
I've moved the security element above resource element to get rid of the cvc-complex-type.2.4.a: according to JaNeLa's help file on the website. In console, it says document is valid but the data might still be wrong!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JNLP 文件存在许多可疑之处。最尤其是它是
test.jnlp
,而且还声称加载同名的扩展!这可能就是导致堆栈溢出的原因。使用 JaNeLA 验证 JNLP。它还将识别其他一些问题。作为 JaNeLA 的作者,我很想知道它是否也抛出 StackOverflowError ,因为它尝试验证主 JNLP 以及任何扩展。我怀疑它会进入无限循环(请报告回来)。
我猜只有一个罐子。如果是这种情况,请删除整个
extension
元素。顺便说一句 - 这个 Jar 真的叫
LoadbonesFOrmat.jar
吗?这是非常奇怪的大写字母使用,我将其称为LoadbonesFormat.jar
或LoadBonesFormat.jar
(即没有大写O
) 。There are a number of suspicious aspects to the JNLP file. Most especially that it is
test.jnlp
but also claims to load an extension of the same name! That might be what is causing the stack overflow.Validate the JNLP using JaNeLA. It will identify some other problems as well. As the author of JaNeLA, I'll be interested to hear if it also throws a
StackOverflowError
, since it tries to validate the main JNLP as well as any extension. I suspect it will go into an infinite loop (please report back).I am guessing there is only the one Jar. If that is the case, remove the entire
extension
element.BTW - is the Jar really called
LoadbonesFOrmat.jar
? That is very odd use of upper case letters, I would have called itLoadbonesFormat.jar
orLoadBonesFormat.jar
(i.e. no upper caseO
).