如何在 Java Web Start (JNLP) 下调试应用程序?

发布于 2024-07-16 01:55:09 字数 163 浏览 8 评论 0 原文

我知道如何使用 Eclipse 调试远程 Java VM,但是如何使用 Java Web Start 程序进行调试呢? 我遇到一个仅在 Java Web Start 中出现的问题。 它必须与安全相关。

我需要一个能够与当前 Java VM(例如 1.6.0_12)配合使用的解决方案。

I know how I can debug a remote Java VM with Eclipse, but how can I do it with a Java Web Start program. I have a problem that only occurs in Java Web Start. It must be security related.

I need a solution that will work with a current Java VM like 1.6.0_12.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

失而复得 2024-07-23 01:55:09

这与您想要远程调试的任何其他 Java 进程完全相同:您必须为 VM 设置一些参数(-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address =12345
),然后连接到给定的端口。 在 Java webstart 6.0 中,可以使用 -J 选项来完成此操作,在早期版本中,可以通过环境变量 JAVAWS_VM_ARGS 来完成。 请参阅此处详细信息。

It's quite the same like with any other Java process you want to debug remotely: You have to set up some arguments for the VM (-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=12345
) and then connect to the given port. In Java webstart 6.0 this can be done with the -J option, in earlier version via environment variable JAVAWS_VM_ARGS. See details here.

甜中书 2024-07-23 01:55:09

手动启动 JWS VM。 这样您就可以提供启动参数来打开调试端口。 这是描述,如下所示:

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 http://server:port/descriptor.jnlp

Start the JWS VM manually. This way you can provide the startup parameters to open the debug port. Here is a description, it goes like this:

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 http://server:port/descriptor.jnlp
香草可樂 2024-07-23 01:55:09

至于较新版本的 Java(Java 8u20+ 和 Java 7u70+),我发现像 -Xrunjdwp 这样的参数不能直接传递,也不能使用 JAVAWS_VM_ARGS。
信息
拒绝指定不安全属性的尝试:-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
开始出现在控制台输出中。

对我有用的唯一解决方案是将这些参数传递到 JAVA_TOOL_OPTIONS 系统变量中。

As for newer versions of Java (Java 8u20+ and Java 7u70+) i experienced that parameters like -Xrunjdwp cannot be passed directly nor using JAVAWS_VM_ARGS.
Message
Rejecting attempt to specify insecure property: -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
started to show up in console output.

The only solution that worked for me was to pass those arguments into JAVA_TOOL_OPTIONS system variable.

め七分饶幸 2024-07-23 01:55:09

您还可以使用 -J 选项向 javaws 可执行文件提供调试参数

示例:

javaws.exe -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 http://server:port/descriptor.jnlp

You can also provide the debug parameter to the javaws executable using the -J option

Example:

javaws.exe -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 http://server:port/descriptor.jnlp
遇见了你 2024-07-23 01:55:09

您需要执行以下操作:

  1. 在 Java 控制面板中启用 Java 日志和跟踪 > 先进的。
    Java 控制面板:日志和跟踪

  2. 启用用于调试 Java 的参数(可选但有用,即 tls/ssl 握手作为 close_notify 或 handshake_failure 出现的问题)& 启动 JNLP,有两种方法可以实现:

    2.a。 下载 JNLP 文件并从命令行执行它(在这种特殊情况下不需要 SET 命令)。

    设置 JAVA_TOOL_OPTIONS=-Djavax.net.debug=all 
      javaws-等待jnlp.jnlp 
      

    2.b. 在 Java 控制面板 > 中为 JVM 添加参数(即 -Djavax.net.debug=all) 爪哇> 查看(这在本例中不是必需的)并从浏览器启动 JNLP 文件:

    “Java

  3. 日志和跟踪位于 log 目录中Java 部署主页 从我粘贴这些位置的地方:

    a. Windows XP:%HOME%\Application Data\Sun\Java\Deployment

    b. Windows 7/Vista:%APPDATA%\..\LocalLow\Sun\Java\Deployment

    c. Linux/Solaris:%HOME%/.java/deployment

使用 javax.net.debug=all,如果 jnlp 内的 jar 是从 https 连接加载的,您将看到握手。 此类问题很难调试。

...
%% No cached client session
*** ClientHello, TLSv1.2
...
***
... 
Java Web Start Main Thread, received EOFException: error
Java Web Start Main Thread, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
Java Web Start Main Thread, SEND TLSv1.2 ALERT:  fatal, description = handshake_failure
Java Web Start Main Thread, WRITE: TLSv1.2 Alert, length = 2
Java Web Start Main Thread, called closeSocket()
#### Java Web Start Error:

You will need to do the following:

  1. Enable the Java logs and tracing in the Java Control Panel > Advanced.
    Java Control Panel: logs and tracing

  2. Enable parameters for debugging Java (optional but useful i.e. problems with tls/ssl handshake as close_notify or handshake_failure) & launching the JNLP, there are two ways you can do it:

    2.a. Download the JNLP file and execute it from command line (the SET command is not required in this particular case).

    set JAVA_TOOL_OPTIONS=-Djavax.net.debug=all
    javaws -wait jnlp.jnlp
    

    2.b. Add arguments (i.e. -Djavax.net.debug=all) for the JVM in the Java Control Panel > Java > View (this is not required in this particular), and launch the JNLP file from browser:

    Java Control Panel: jvm arguments

  3. The logs and traces are located in the log directory from the Java Deployment Home from where I paste these locations:

    a. Windows XP: %HOME%\Application Data\Sun\Java\Deployment

    b. Windows 7/Vista: %APPDATA%\..\LocalLow\Sun\Java\Deployment

    c. Linux/Solaris: %HOME%/.java/deployment

With javax.net.debug=all you will see the handshake if the jar inside the jnlp is loaded from an https connection. This kind of problems are hard to debug.

...
%% No cached client session
*** ClientHello, TLSv1.2
...
***
... 
Java Web Start Main Thread, received EOFException: error
Java Web Start Main Thread, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
Java Web Start Main Thread, SEND TLSv1.2 ALERT:  fatal, description = handshake_failure
Java Web Start Main Thread, WRITE: TLSv1.2 Alert, length = 2
Java Web Start Main Thread, called closeSocket()
#### Java Web Start Error:
冰雪之触 2024-07-23 01:55:09

您可以在启用调试的情况下运行 JNLP:

javaws -Xnosplash -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5009 <application>.jnlp

输出:
监听地址:5009处的传输dt_socket

使用您最喜欢的IDE附加到此,我使用IntelliJ IDEA
运行>附加到进程

You can run your JNLP with debugging enabled:

javaws -Xnosplash -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5009 <application>.jnlp

Output:
Listening for transport dt_socket at address: 5009

Attach to this with your favorite IDE, I use IntelliJ IDEA
Run>Attach to process

断舍离 2024-07-23 01:55:09

对于 Java 8 和 Windows 10,打开命令提示符 (cmd.exe) 并键入以下内容:

set JAVAWS_TRACE_NATIVE=1
set JAVA_TOOL_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
javaws java-app.jnlp

之后,在 Eclipse(或其他 IDE)中启动正常的远程 Java 应用程序调试,并将其设置为上述命令中使用的端口(在本例中 <代码>8000)

With Java 8 and Windows 10, open command prompt (cmd.exe) and type this:

set JAVAWS_TRACE_NATIVE=1
set JAVA_TOOL_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
javaws java-app.jnlp

After that, in Eclipse (or another IDE) start the normal remote java application debugging set to the port used in the command above (in this case 8000)

甜是你 2024-07-23 01:55:09

要在 Linux 中调试 Web Start 应用程序,请创建一个 shell 脚本 ~/bin/javaws-debug.sh,并在调试模式下调用 javaws,如上所述:

~/bin/javaws-debug.sh:

#!/bin/sh
export JAVAWS_TRACE_NATIVE=1
export JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE 
  -Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=n"
javaws "$@"

然后,在浏览器中选择该脚本作为在 jnlp 文件上调用的应用程序。

例如,在 Firefox 中,转到编辑→首选项→应用程序,内容类型:Java Web Start,然后在操作中选择“使用其他”,然后从“选择帮助程序应用程序”对话框中选择脚本。 在 Chrome 中,您需要更改 Linux 系统设置。 在 KDE 中,转到系统设置→文件关联,已知类型:application:x-java-jnlp-file,添加一个新应用程序,从“为 application/x-java 选择应用程序”中选择 ~/bin/javaws-debug.sh -jnlp-文件”对话框。

配置浏览器后,Java Web Start 应用程序将开始使用您的包装器,这将使调试器能够连接到端口 8989。

To debug a Web Start application in Linux, create a shell script ~/bin/javaws-debug.sh with the javaws invocation in debug mode as described above:

~/bin/javaws-debug.sh:

#!/bin/sh
export JAVAWS_TRACE_NATIVE=1
export JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE 
  -Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=n"
javaws "$@"

Then, in your browser, choose that script as the application to invoke on jnlp files.

For example, in Firefox, go to Edit→Preferences→Applications, Content Type: Java Web Start, and choose "Use Other" in Action and pick the script from the "Select Helper Application" dialog. In Chrome, you need to alter Linux system settings. In KDE, go to System Settings→File Associations, Known Types: application:x-java-jnlp-file, add a new Application, pick ~/bin/javaws-debug.sh from the "Choose Application for application/x-java-jnlp-file" dialog.

Once your browser is configured, Java Web Start application will start using your wrapper, which will enable debugger to connect on port 8989.

三月梨花 2024-07-23 01:55:09

您是否尝试过打印调试日志? 无论如何,这是一件有用的事情,并且在这种情况下可能会有所帮助。

如果您想要真正的调试,请参见此处:
如何在 WebStart 下进行调试?

Have you tried printing a debug log? That is a useful thing to have at any rate, and might help in this case.

If you want real debugging, see e.g. here:
How can I debug under WebStart?

纸短情长 2024-07-23 01:55:09

这对我有用 IcedTea-Web

set JAVAWS_TRACE_NATIVE=1
set JAVA_TOOL_OPTIONS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=y
javaws -Xnofork my_jnlp_file.jnlp

选项 -Xnofork 是必需的,否则设置不适用于应用程序的分叉 jvm。

This is what worked for me with IcedTea-Web :

set JAVAWS_TRACE_NATIVE=1
set JAVA_TOOL_OPTIONS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=y
javaws -Xnofork my_jnlp_file.jnlp

Option -Xnofork was required or else the settings didn't apply to the forked jvm of the application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文