This may not be a Tomcat bug, but I think it best to report it here as it's more likely the Tomcat team will be able to find the root cause. The attached web application WAR does nothing other than define a <servlet> that comes out of the box with Velocity and Velocity Tools. The mere presence of this servlet appears to cause the JVM to reject certain Attach API connections -- such as those from jconsole, VisualVM, and other profiling tools. VisualVM will connect after an error ("attach: task_for_pid(23490) failed (5)" in the console, longer stack trace available which basically says "couldn't connect") but the JMX tab will be unavailable. Any help with discovering the root cause of this issue would be greatly appreciated.
Created attachment 31379 [details] Minimal web application WAR that reproduces the problem. I had to remove the following files to reduce the size enough to attach to the BZ issue. They should be trivially-retrievable from ASF's web site(s): deleting: WEB-INF/lib/commons-beanutils-1.8.3.jar deleting: WEB-INF/lib/commons-collections-3.2.1.jar deleting: WEB-INF/lib/commons-digester-1.8.jar deleting: WEB-INF/lib/commons-lang-2.4.jar deleting: WEB-INF/lib/commons-logging-1.1.1.jar
Might me Mac/JVM specific. Konstantin was unable to reproduce on Windows.
If you start Tomcat with -Xverify:none (not something I'd recommend doing) the problem goes away. This looks like a VisualVM bug that is triggered by one of the velocity classes. As an alternative, attach VisualVM and then deploy the Velocity app. For those wondering how I stumbled across the solution: 1. Google "attach: task_for_pid(23490) failed (5)" 2. Read through the VisualVm bug reports that finds 3. Specifically read this one: https://java.net/jira/browse/VISUALVM-326 4. Experiment with the settings suggested in that report to see which are actually required I'd recommend opening a VisalVM bug for this. I concur that this is a Mac specific error.
I'll give -x:verify:none a try (on the client?) but this also happens with both jconsole and YourKit. Might this be an underlying JVM bug? I didn't try with other versions (e.g. OpenJDK, IBM, or Sun/Oracle Java 6) yet.