Bug 786082 - tomcat as a service is not properly detected
tomcat as a service is not properly detected
Status: CLOSED CURRENTRELEASE
Product: JBoss Enterprise Web Server 2
Classification: JBoss
Component: JON Plugin (Show other bugs)
2.0.0
All Windows
unspecified Severity high
: ER04
: ---
Assigned To: Jean-frederic Clere
Libor Fuka
:
Depends On:
Blocks: 1111666
  Show dependency treegraph
 
Reported: 2012-01-31 06:43 EST by Tom Fonteyne
Modified: 2014-08-21 17:40 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Previously in JBoss Enterprise Web Server, the JON Tomcat plugin was not able to discover Tomcat installed as a Microsoft Windows service. In JBoss Enterprise Web Server 2.1, the JON Tomcat plugin is now fixed so that Tomcat is discovered as expected.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-08-21 17:40:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 69636 None None None Never

  None (edit)
Description Tom Fonteyne 2012-01-31 06:43:00 EST
Description of problem:

tomcat as a service is not properly detected due to different command line detection needed


Version-Release number of selected component (if applicable):

2.4.1, 3.0.0

How reproducible:

always

Steps to Reproduce:
1. Install the exe version of Tomcat 6 on Windows, and have it installed as a service (the installer allows that, or do it manually).
2. Start the service.
3. install an agent on windows
4. discovery -f

Actual results:

Tomcat is not found

Expected results:

The opposite..... to find tomcat

Additional info:

when starting as a service, task manager in windows will show the process as:

Image name: tomcat6.exe
User: SYSTEM
Command line: "c:\path\Tomcat 6.0.33\bin\Tomcat6.exe" //RS/Tomcat6

(use menu: View/Select columns  to make the cmd line visible)

Looking at:

modules/plugins/tomcat/src/main/java/org/​boss/on/​plugins/tomcat/​ TomcatDiscoveryComponent.java

241 String catalinaHome = determineCatalinaHome(commandLine);
242 
243 if (catalinaHome == null && isWindows(context)) {
244    log.debug("catalina.home not found. ...
...
250     catalinaHome = determineCatalinaHomeOnWindows(processInfo);
251  }

determineCatalinaHome in line 241 returns null, looking at it:

321     private String determineCatalinaHome(String[] cmdLine) {
322         String result = null;
323 
324         for (int i = 0; i < cmdLine.length; ++i) {
325             String line = cmdLine[i];
326             if (line.startsWith(PROPERTY_CATALINA_HOME)) {
327                 result = line.substring(PROPERTY_CATALINA_HOME.length());
328                 break;
329             }
330         }

This test will always fail of course for a windows service - see command line format above.

So we fall throught to line 250 determineCatalinaHomeOnWindows
There the code relies on "apache-tomcat-" directory, so relying on it being a EWS tomcat only, hence fails again to discover out tomcat service.

When determineCatalinaHomeOnWindows() fails to find anything, an additional test should be done with a simple JMX connection that reads out the JVM arguments. The only caveat, is that a fixed/documented port number should be used which would limit detection to a single tomcat instance.

Cross referencing: https://bugzilla.redhat.com/show_bug.cgi?id=756456

as that BZ is also about Tomcat as a service.
Comment 1 Tom Fonteyne 2012-01-31 07:02:40 EST
Also tested on 2.4.2rc4, also failing as expected.
Comment 3 mark yarborough 2012-11-06 15:05:26 EST
Per 3.1.2 triage with loleary, mfoley, ccrouch, asantos: Okay to move to JON 3.2.
Comment 5 Jean-frederic Clere 2013-05-08 05:15:55 EDT
In fact it works with EWS so just tell the customers to use EWS.
Comment 6 Libor Fuka 2013-05-15 10:50:59 EDT
I verified with EWS2 Tomcat6,7 installed as Windows service + JON 3.1.2.GA + updated Tomcat plugin (brew build [1])
[1] https://brewweb.devel.redhat.com//buildinfo?buildID=269954

Cross referencing: https://bugzilla.redhat.com/show_bug.cgi?id=963264

Where i add steps how to properly install EWS Tomcat as windows service with JON Tomcat plugin and get it all works.
Comment 7 Larry O'Leary 2013-06-20 13:52:33 EDT
Moving this back to NEW as this doesn't appear to be fixed. It only works if the user creates hacks together a new script to get around this failure.

There should be no "special steps" to install EWS as a service when using it with JBoss ON. Instead, the managed plug-in should handle this situation within its discovery code. Asking the user to hack the startup scripts and officially supported startup process doesn't seem like an acceptable solution. Yes, perhaps a workaround, but doesn't warrant this bug to be VERIFIED.
Comment 9 Jean-frederic Clere 2014-03-07 08:52:32 EST
Fixed by https://github.com/rhq-project/rhq/pull/8
Comment 11 Libor Fuka 2014-07-18 10:19:50 EDT
VERIFIED on MS Windows Server 2008 (32bit) + JON 3.2.0.GA (update02) + JON Tomcat plugin (update01) + OracleJDK 1.6 + EWS ER4 Tomcat6/7
Comment 12 Larry O'Leary 2014-08-21 17:40:15 EDT
This fix, change, or update was tested and released in Web Server Plugin Pack Update-01 for JBoss ON 3.2 -- https://access.redhat.com/jbossnetwork/restricted/softwareDetail.html?softwareId=32543

Note You need to log in before you can comment on or make changes to this bug.