Bug 56242 - Deploying a Velocity-based web application can thwart Attach API connections for monitoring
Summary: Deploying a Velocity-based web application can thwart Attach API connections ...
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.x-trunk
Hardware: PC All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-10 18:03 UTC by Christopher Schultz
Modified: 2014-03-11 19:55 UTC (History)
0 users



Attachments
Minimal web application WAR that reproduces the problem. (716.19 KB, application/octet-stream)
2014-03-10 18:09 UTC, Christopher Schultz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Schultz 2014-03-10 18:03:32 UTC
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.
Comment 1 Christopher Schultz 2014-03-10 18:09:51 UTC
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
Comment 2 Christopher Schultz 2014-03-10 21:11:59 UTC
Might me Mac/JVM specific. Konstantin was unable to reproduce on Windows.
Comment 3 Mark Thomas 2014-03-11 09:39:34 UTC
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.
Comment 4 Christopher Schultz 2014-03-11 19:55:12 UTC
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.