This section helps you solve problems involving the Attach
API.
The IBM® Java™ Attach API uses shared semaphores, sockets,
and file system artifacts to implement the attach protocol. Problems
with these artifacts might adversely affect the operation of applications
when they use the attach API.
Note: Error messages from agents on the
target VM go to stderr or stdout for
the target VM. They are not reported in the messages output by the
attaching VM.
Deleting files in /tmp
The
attach API depends on the contents of a common directory. By default
the common directory is
/tmp/.com_ibm_tools_attach.
Problems are caused if you modify the common directory in one of the
following ways:
- Deleting the common directory.
- Deleting the contents of the common directory.
- Changing the permissions of the common directory or any of its
content.
If you do modify the common directory, possible effects include:
- Semaphore "leaks" might occur, where excessive numbers of
unused shared semaphores are opened. You can remove the semaphores
using the command:
ipcrm -s <semid>
Use the
command to delete semaphores that have keys starting with "0xa1".
- The Java VMs might not be
able to list existing target VMs.
- The Java VMs might not be
able to attach to existing target VMs.
- The Java VM might not be
able to enable its attach API.
If the common directory cannot be used, a Java VM attempts to recreate the common directory.
However, the JVM cannot recreate the files related to currently executing
VMs.
The VirtualMachine.attach(String id) method
reports AttachNotSupportedException: No provider for
virtual machine id
There are several possible
reasons for this message:
- The target VM might be owned by another userid. The attach API
can only connect a VM to a target VM with the same userid.
- The attach API for the target VM might not have launched yet.
There is a short delay from when the Java VM
launches to when the attach API is functional.
- The attach API for the target VM might have failed. Verify that
the directory /tmp/.com_ibm_tools_attach/<id> exists,
and that the directory is readable and writable by the userid.
- The target directory /tmp/.com_ibm_tools_attach/<id> might
have been deleted.
- The attach API might not have been able to open the shared semaphore.
To verify that there is at least one shared semaphore, use the command:
ipcs -s
If
there is a shared semaphore, at least one key starting with "0xa1" appears
in the output from the ipcs command.Note: The number
of available semaphores is limited on systems which use System V IPC,
including Linux®, z/OS®, and AIX®.
The VirtualMachine.attach() method
reports AttachNotSupportedException
There
are several possible reasons for this message:
- The target process is dead or suspended.
- The target process, or the hosting system is heavily loaded. The
result is a delay in responding to the attach request.
- The network protocol has imposed a wait time on the port used
to attach to the target. The wait time might occur after heavy use
of the attach API, or other protocols which use sockets. To check
if any ports are in the TIME_WAIT state, use the
command:
netstat -a
The VirtualMachine.loadAgent(), VirtualMachine.loadAgentLibrary(),,
or VirtualMachine.loadAgentPath() methods report com.sun.tools.attach.AgentLoadException or com.sun.tools.attach.AgentInitializationException
There
are several possible reasons for this message:
- The JVMTI agent or the agent JAR file might be corrupted. Try
loading the agent at startup time using the -javaagent, -agentlib,
or -agentpath option, depending on which method reported
the problem.
- The agent might be attempting an operation which is not available
after VM startup.
A process running as root can see a target using AttachProvider.listVirtualMachines(),
but attempting to attach results in an AttachNotSupportedException
A process can attach only to processes owned by the
same user. To attach to a non-root process from a root process, first
use the su command to change the effective UID
of the attaching process to the UID of the target UID, before attempting
to attach.