1

When I'm trying to use attach api I'm getting an error

com.sun.tools.attach.AttachNotSupportedException: Invalid process identifier

I'm connecting with VirtualMachine vmRemote = VirtualMachine.attach("rmi://<processid>@<server_name>:1099"); My desctop is windows based and remote server is linux. As I catch tools.jar consists of only sun.tools.attach.WindowsAttachProvider may be it leads to this problem? During connection I could see in jstatd log

FINER: RMI TCP Connection(10)#####: [######: sun.tools.jstatd.RemoteVmImpl[-6dd825ef:15ab396432e:-7fe5, -3475770279103225284]: public abstract int sun.jvmstat.monitor.remote.RemoteVm.getCapacity() throws java.rmi.RemoteException]
Victor Garbuz
  • 75
  • 1
  • 8
  • Seems I've found the problem! I've checked sources from OpenJDK and found that in method WindowsAttachProvider#attachVirtualMachine we have new WindowsVirtualMachine(this, vmid); in constructor we have pid = Integer.parseInt(id); and this call of course throws exception – Victor Garbuz Mar 10 '17 at 07:14
  • 1
    It looks like you are mixing up JMX and the attach API. You can connect to local and remote JVMs via JMX, if the JMX agent already runs in the target JVM. You can use the Attach API to find local JVMs, connect to a local JVM and start the JMX agent, if it doesn’t run already. Of course, a process id is a process id and not an rmi URI. The fact tat the process id is supposed to be a number under Windows, is only a symptom of the problem, connecting to a remote Linux process via the WindowsAttachProvider won’t work, regardless of what you specify. – Holger Mar 10 '17 at 10:20

0 Answers0