Skip to main content

AttachAPI fails on Mac when java.io.tmpdir is defined for parent process but not for forked process

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
scooper4711
Offline
Joined: 2008-10-22

I have a project in Maven where I want to pass in a new value for the java.io.tempdir.

This works fine when running on linux or windows, but it fails on Mac with the following stack trace:

<span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Lucida Console', Monaco, 'DejaVu Sans Mono', monospace; line-height: normal; white-space: pre-wrap; background-color: rgb(255, 255, 255); ">Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded</span>

at sun.tools.attach.MacosxVirtualMachine.&lt;init&gt;(MacosxVirtualMachine.java:82)
at sun.tools.attach.MacosxAttachProvider.attachVirtualMachine(MacosxAttachProvider.java:34)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:195)

Looking at the code, it would appear that MacosxVirtualMachine is relying on finding a file nameed .java_pid<int> in the java.io.tmpdir directory.

Unfortunately, it appears that java.io.tmpdir is different for the parent process and the child process, (according to http://jira.codehaus.org/browse/SUREFIRE-764) so the file is not found.

Whatever code that windows or linux uses is not relying on the pid file being in the tmp directory, so it works.

This error has been found and reported here: http://code.google.com/p/jmockit/issues/detail?id=190 and also here: http://openejb.97944.n4.nabble.com/openejb-3-1-error-on-start-under-SnowLeopard-td2291203.html

It appears to be a bug specific to MacosxAttachProvider/MacosxVirtualMachiine.