简体   繁体   中英

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 .

It is possible to pass command line switches to Nuix, some of which it passes to the JVM.

Nuix is packaged with JRE 8 in one of its subdirectories: \\Nuix 7.4\\jre\\ . It appears that the particular version is Java HotSpot(TM) 64-Bit Server VM 1.8.0_92.

I launched Nuix with these switches:

-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. I tried creating a remote connection using jdb.exe -attach <Port> , but the application failed with this exception.

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.

What the proper way to attach a debugger?

As a side question, how is it possible for a Windows .exe to use JARs? 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.

To attach a debugger, I did the following. Note that I used port 80 due to a firewall configuration that I cannot alter. I realize that port 8000 is the conventional Java debug port.

jconsole.exe

  1. Start Nuix with this switch.

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

  3. Run jconsole.exe <PID> .

jdb.exe

  1. Start Nuix with this switch.

     -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80 
  2. Run jdb.exe with these switches:

     jdb -connect com.sun.jdi.SocketAttach:port=80 
  3. Type run to take Nuix out of suspend mode.

Eclipse Mars

  1. Start Nuix with this switch.

     -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80 
  2. Go to Run -> Debug Configurations... -> Remote Java Application.

  3. Configure

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

  5. Go to Window -> Perspective -> Open Perspective -> Java.

Java Mission Control (jmc.exe)

  1. Start Nuix with these switches

     -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.

  3. Configure options

     Host = 127.0.0.1 Port = 80 
  4. Click the Test Connection button.

VisualVM 1.4

  1. Start Nuix with these switches

     -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....

  3. Set the connection to localhost:80 , and Click OK.

  4. In the Applications tree, double-click localhost:80 (pid: [process ID])


Running the JVM from a Windows Process

Based on the presence of JavaAccessBridge-64.dll, I believe that Nuix uses Java Access Bridge .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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