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
Start Nuix with this switch.
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80
Get the Windows process ID of nuix_app.exe.
jconsole.exe <PID>
.jdb.exe
Start Nuix with this switch.
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80
Run jdb.exe with these switches:
jdb -connect com.sun.jdi.SocketAttach:port=80
Type run
to take Nuix out of suspend mode.
Eclipse Mars
Start Nuix with this switch.
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80
Go to Run -> Debug Configurations... -> Remote Java Application.
Configure
Connection Type = Standard (Socket Attach)
Host = localhost
Port = 80
Click Debug
.
Java Mission Control (jmc.exe)
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
Click Create a new custom JVM Connection.
Configure options
Host = 127.0.0.1
Port = 80
Click the Test Connection button.
VisualVM 1.4
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
In the Applications tree, right-click Local, and then click Add JMX Connection....
Set the connection to localhost:80
, and Click OK.
In the Applications tree, double-click localhost:80 (pid: [process ID])
Based on the presence of JavaAccessBridge-64.dll, I believe that Nuix uses Java Access Bridge.