bili
bili

Reputation: 610

JWS stack overflow error

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:

  1. Something is wrong with the jar file (I didn't export it correctly)
  2. 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!

Upvotes: 1

Views: 1228

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168815

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 it LoadbonesFormat.jar or LoadBonesFormat.jar (i.e. no upper case O).

Upvotes: 2

Related Questions