JNLP中的JVM类加载器跟踪选项

时间:2018-04-03 06:31:33

标签: java debugging jnlp

我正在尝试调试通过JNLP运行的java clied中的类加载问题。但-XX:+TraceClassLoading仅打印'已加载'事件,仅适用于核心类。另一个选项-verbose:class什么也没做。我尝试用D和X作为前缀而没有效果。

当我在桌面java应用程序中使用-verbose:class时,它会打印所有事件,但这里不会发生错误。

我是否遗漏了某些内容,或者是否有其他方法可以跟踪JNLP中的类加载?

修改
我尝试过的例子(这是javaws调用扩展到的内容):

/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

JNLP运行的部分输出(无用户类):

[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]

从桌面java运行的部分输出(注意来自.m2 repo的用户类,是的,它是在_151上运行但是没有区别,我试过了两个):

[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建议将选项传递给jnlp的另一种方法,但它也只打印核心类。我想,这是因为选项只传递给第一个java调用,它只管理部署,然后再调用实际的应用程序。

1 个答案:

答案 0 :(得分:2)

我找到了一种解决方法,但仍然对正常的方法感兴趣

解决方法

  1. 运行javaws http://localhost:8080/webstart.jnlp并等待一段时间以便部署并启动
  2. 运行ps -ax | grep Djnlpx并复制完全展开的JNLP调用
  3. 从p1
  4. 关闭申请
  5. 从p2添加-verbose:class(或您想要的任何其他选项)并再次运行。
  6. 说明

    我发现javaws调用扩展了两次。所以,基本电话是

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

    如果我尝试在此处添加任何选项,则无效。 它扩展为

    /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
    

    换行符是为了便于阅读,您必须删除它们。如果你把-verbose:class放在这里,它只打印核心类。那个电话会扩展为:

    /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
    

    再次划线以获得可读性。如果您在此处放置-verbose:class,则会打印所有课程事件。