3

I'm trying to debug class loading issue in a java clied that is being run via JNLP. But -XX:+TraceClassLoading only prints 'Loaded' events and only for core classes. The other option, -verbose:class does nothing. I tried to prefix it with D and X without effect.

When I use -verbose:class in a desktop java application, it prints all events just fine, but the bug does not occur here.

Am I missing something or is there another way to trace class loading in JNLP?

Edit:
Examples of what I tried (this is what javaws call expands into):

/usr/lib/jvm/jdk1.8.0_161/jre/bin/java -classpath /usr/lib/jvm/jdk1.8.0_161/jre/lib/deploy.jar -Djava.security.policy=file:/usr/lib/jvm/jdk1.8.0_161/jre/lib/security/javaws.policy -DtrustProxy=true -verbose:class -XX:+TraceClassLoading -Xverify:remote -Djnlpx.home=/usr/lib/jvm/jdk1.8.0_161/jre/bin -Djava.security.manager -Djnlpx.origFilenameArg=http://localhost:8080/webstart.jnlp -Djnlpx.remove=false -Dsun.awt.warmup=true -Xbootclasspath/a:/usr/lib/jvm/jdk1.8.0_161/jre/lib/javaws.jar:/usr/lib/jvm/jdk1.8.0_161/jre/lib/deploy.jar:/usr/lib/jvm/jdk1.8.0_161/jre/lib/plugin.jar -Djnlpx.splashport=59367 -Djnlpx.jvm=/usr/lib/jvm/jdk1.8.0_161/jre/bin/java com.sun.javaws.Main -notWebJava http://localhost:8080/webstart.jnlp

Partial output from JNLP run (no user classes):

[Loaded java.lang.UNIXProcess$$Lambda$15/1173574345 from java.lang.UNIXProcess]
[Loaded com.sun.javaws.Launcher$CacheUpdateRequiredException from /usr/lib/jvm/jdk1.8.0_161/jre/lib/javaws.jar]
[Loaded java.lang.SecurityException from /usr/lib/jvm/jdk1.8.0_161/jre/lib/rt.jar]
[Loaded com.sun.deploy.security.BlockedException from /usr/lib/jvm/jdk1.8.0_161/jre/lib/deploy.jar]
[Loaded sun.awt.X11.XSystemTrayPeer from /usr/lib/jvm/jdk1.8.0_161/jre/lib/rt.jar]

Partial output from desktop java run (notice user classes from .m2 repo and yes, it was run on _151 but there is no difference, I tried both):

[Loaded <...>.UnmodifiableArrayIterator from file:/home/imaskar/.m2/repository/<...>/1.6-SNAPSHOT/<...>-1.6-SNAPSHOT-jar-with-dependencies.jar]
[Loaded <...>.RCEvent from file:/home/imaskar/.m2/repository/<...>/1.6-SNAPSHOT/<...>-1.6-SNAPSHOT-jar-with-dependencies.jar]
[Loaded <...>.RCMessengerQualityListener$1 from file:/home/imaskar/.m2/repository/<...>/1.6-SNAPSHOT/<...>-1.6-SNAPSHOT.jar]
[Loaded javax.swing.JComponent$$Lambda$124/1794174740 from javax.swing.JComponent]
[Loaded java.util.prefs.FileSystemPreferences$10 from /usr/lib/jvm/jdk1.8.0_151/jre/lib/rt.jar]
[Loaded java.util.prefs.FileSystemPreferences$12 from /usr/lib/jvm/jdk1.8.0_151/jre/lib/rt.jar]
[Loaded java.util.prefs.FileSystemPreferences$11 from /usr/lib/jvm/jdk1.8.0_151/jre/lib/rt.jar]

Edit2:

Here is suggested another method of passing options to jnlp, but it also prints only core classes. I suppose, it happens because options only passed to the first java call, which only manages deployment and then makes another call to the actual application.

Imaskar
  • 2,773
  • 24
  • 35

1 Answers1

2

Workaround

  1. run javaws http://localhost:8080/webstart.jnlp and wait a bit so it deploys and starts
  2. run ps -ax | grep Djnlpx and copy fully expanded JNLP call
  3. close application from p1
  4. add -verbose:class (or any other option you want) to the call from p2 and run again.

Explanation

I found that javaws call expands twice. So, basic call is

javaws http://localhost:8080/sin-web/webstart.jnlp

If I try to add any options here, nothing works. It expands into

/usr/lib/jvm/jdk1.8.0_151/jre/bin/java
 -classpath
 /usr/lib/jvm/jdk1.8.0_151/jre/lib/deploy.jar
 -Djava.security.policy=file:/usr/lib/jvm/jdk1.8.0_151/jre/lib/security/javaws.policy
 -DtrustProxy=true
 -Xverify:remote
 -Djnlpx.home=/usr/lib/jvm/jdk1.8.0_151/jre/bin
 -Djava.security.manager
 -Djnlpx.origFilenameArg=http://localhost:8080/sin-web/webstart.jnlp
 -Djnlpx.remove=false
 -Dsun.awt.warmup=true
 -Xbootclasspath/a:/usr/lib/jvm/jdk1.8.0_151/jre/lib/javaws.jar:/usr/lib/jvm/jdk1.8.0_151/jre/lib/deploy.jar:/usr/lib/jvm/jdk1.8.0_151/jre/lib/plugin.jar
 -Djnlpx.splashport=44975
 -Djnlpx.jvm=/usr/lib/jvm/jdk1.8.0_151/jre/bin/java
 com.sun.javaws.Main
 -verbose
 -notWebJava
 http://localhost:8080/sin-web/webstart.jnlp

Line breaks for readability, you have to remove them. If you put -verbose:class here it only prints core classes. And that call expands into:

/usr/lib/jvm/jdk1.8.0_161/jre/bin/java 
-Xmx1g -Xms256m 
-Djnlp.packEnabled=false 
-Xbootclasspath/a:/usr/lib/jvm/jdk1.8.0_161/jre/lib/javaws.jar:/usr/lib/jvm/jdk1.8.0_161/jre/lib/deploy.jar:/usr/lib/jvm/jdk1.8.0_161/jre/lib/plugin.jar 
-Djnlp.tk=awt 
-classpath /usr/lib/jvm/jdk1.8.0_161/jre/lib/deploy.jar -Djnlpx.vmargs=LVhteDFnAC1YbXMyNTZtAC1Eam5scC5wYWNrRW5hYmxlZD1mYWxzZQA= -Djnlpx.jvm=/usr/lib/jvm/jdk1.8.0_161/jre/bin/java 
-Djnlpx.splashport=59367 
-Djnlpx.home=/usr/lib/jvm/jdk1.8.0_161/jre/bin 
-Djnlpx.remove=false 
-Djnlpx.offline=false 
-Djnlpx.relaunch=true 
-Djnlpx.session.data=/tmp/session2497443162302588696 
-Djnlpx.heapsize=NULL,NULL 
-Djava.security.policy=file:/usr/lib/jvm/jdk1.8.0_161/jre/lib/security/javaws.policy 
-DtrustProxy=true 
-Xverify:remote 
-Djnlpx.origFilenameArg=http://localhost:8080/webstart.jnlp 
-Dsun.awt.warmup=true 
-Djava.security.manager 
com.sun.javaws.Main 
-notWebJava 
/home/imaskar/.java/deployment/cache/6.0/1/40a358c1-677ef294

Line breaks for readablility again. If you put -verbose:class here, all classes events are printed.

Imaskar
  • 2,773
  • 24
  • 35