简体   繁体   English

在Nuix中调试Java应用程序-附加探查器或调试器

[英]Debug Java Application in Nuix - Attach a Profiler or Debugger

My goal is to attach a Java profiler or debugger to an instance of the Java Virtual Machine started by a Windows application called Nuix . 我的目标是将Java事件探查器或调试器附加到由Windows应用程序Nuix启动的Java虚拟机实例。

It is possible to pass command line switches to Nuix, some of which it passes to the JVM. 可以将命令行开关传递给Nuix,其中一些传递给JVM。

Nuix is packaged with JRE 8 in one of its subdirectories: \\Nuix 7.4\\jre\\ . Nuix与JRE 8打包在其子目录之一中: \\Nuix 7.4\\jre\\ It appears that the particular version is Java HotSpot(TM) 64-Bit Server VM 1.8.0_92. 似乎特定的版本是Java HotSpot™64位服务器VM 1.8.0_92。

I launched Nuix with these switches: 我使用以下开关启动了Nuix:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80

I then tried running jconsole.exe without command line switches, and it did not recognize the JVM started by Nuix. 然后,我尝试在没有命令行开关的情况下运行jconsole.exe ,但它无法识别Nuix启动的JVM。 I tried creating a remote connection using jdb.exe -attach <Port> , but the application failed with this exception. 我尝试使用jdb.exe -attach <Port>创建远程连接,但是应用程序失败,出现此异常。

java.io.IOException: shmemBase_attach failed: The system cannot find the file specified

I verified that nothing else is listening on port 80 and it is not blocked. 我确认没有其他东西在端口80上监听,并且没有被阻塞。

What the proper way to attach a debugger? 附加调试器的正确方法是什么?

As a side question, how is it possible for a Windows .exe to use JARs? 附带的问题是,Windows .exe如何使用JAR? I have not seen this architecture before, and I do not believe IKVM.NET is used, and J# is not used because the application is unmanaged, according to Process Explorer. 根据Process Explorer,我以前从未见过这种体系结构,也不相信会使用IKVM.NET,也不会使用J#,因为该应用程序不受管理。

To attach a debugger, I did the following. 要附加调试器,我做了以下工作。 Note that I used port 80 due to a firewall configuration that I cannot alter. 请注意,由于防火墙配置无法更改,我使用了端口80。 I realize that port 8000 is the conventional Java debug port. 我意识到端口8000是常规的Java调试端口。

jconsole.exe jconsole.exe

  1. Start Nuix with this switch. 使用此开关启动Nuix。

     -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80 
  2. Get the Windows process ID of nuix_app.exe. 获取Windows进程ID nuix_app.exe。

  3. Run jconsole.exe <PID> . 运行jconsole.exe <PID>

jdb.exe 可执行文件

  1. Start Nuix with this switch. 使用此开关启动Nuix。

     -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80 
  2. Run jdb.exe with these switches: 使用以下开关运行jdb.exe:

     jdb -connect com.sun.jdi.SocketAttach:port=80 
  3. Type run to take Nuix out of suspend mode. 键入run以使Nuix退出挂起模式。

Eclipse Mars 蚀火星

  1. Start Nuix with this switch. 使用此开关启动Nuix。

     -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80 
  2. Go to Run -> Debug Configurations... -> Remote Java Application. 转到运行->调试配置...->远程Java应用程序。

  3. Configure 配置

     Connection Type = Standard (Socket Attach) Host = localhost Port = 80 
  4. Click Debug . 点击Debug

  5. Go to Window -> Perspective -> Open Perspective -> Java. 转到窗口->透视图->打开透视图-> Java。

Java Mission Control (jmc.exe) Java任务控制(jmc.exe)

  1. Start Nuix with these switches 使用这些开关启动Nuix

     -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=80 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1 
  2. Click Create a new custom JVM Connection. 单击创建新的自定义JVM连接。

  3. Configure options 配置选项

     Host = 127.0.0.1 Port = 80 
  4. Click the Test Connection button. 单击测试连接按钮。

VisualVM 1.4 VisualVM 1.4

  1. Start Nuix with these switches 使用这些开关启动Nuix

     -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=80 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1 
  2. In the Applications tree, right-click Local, and then click Add JMX Connection.... 在“应用程序”树中,右键单击“本地”,然后单击“添加JMX连接...”。

  3. Set the connection to localhost:80 , and Click OK. 将连接设置为localhost:80 ,然后单击确定。

  4. In the Applications tree, double-click localhost:80 (pid: [process ID]) 在“应用程序”树中,双击“ localhost:80”(pid:[进程ID])


Running the JVM from a Windows Process 从Windows进程运行JVM

Based on the presence of JavaAccessBridge-64.dll, I believe that Nuix uses Java Access Bridge . 基于JavaAccessBridge-64.dll的存在,我相信Nuix使用Java Access Bridge

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM