0

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.

Jacob Quisenberry
  • 1,131
  • 3
  • 20
  • 48
  • 1
    `As a side question, how is it possible for a Windows .exe to use JARs?` In exactly the same way as a shell script can. Since the entire Java VM is included in the distribution, you can just start it as a separate process. – biziclop May 22 '14 at 20:56
  • Using Process Monitor, I believe that \jre\bin\java.dll is responsible for loading the JARs. Is that a known method for making JARs accessible to a Windows application? @biziclop – Jacob Quisenberry May 22 '14 at 21:19
  • 1
    The .exe is a wrapper which calls JNI_CreateJavaVM to start up the JVM. It also loads some memory preferences from the registry to pass to the JVM (i.e. via -Xmx). – Luke Quinane Aug 06 '14 at 01:19

1 Answers1

0

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.

Jacob Quisenberry
  • 1,131
  • 3
  • 20
  • 48