Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 829784 Details for
Bug 1035348
Tomcat servers not discovered on Windows when installed as a service
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Only EWS services were supported
Bug_1035348.patch (text/plain), 16.25 KB, created by
Thomas Segismont
on 2013-11-27 15:50:14 UTC
(
hide
)
Description:
Only EWS services were supported
Filename:
MIME Type:
Creator:
Thomas Segismont
Created:
2013-11-27 15:50:14 UTC
Size:
16.25 KB
patch
obsolete
>Index: modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatDiscoveryComponent.java >IDEA additional info: >Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP ><+>ISO-8859-1 >=================================================================== >--- modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatDiscoveryComponent.java (revision d28e22f0c77f127efe6ff3f63f0f82e22c20083a) >+++ modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatDiscoveryComponent.java (revision ) >@@ -1,24 +1,20 @@ > /* >- * Jopr Management Platform >- * Copyright (C) 2005-2008 Red Hat, Inc. >+ * RHQ Management Platform >+ * Copyright (C) 2005-2013 Red Hat, Inc. > * All rights reserved. > * > * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License, version 2, as >- * published by the Free Software Foundation, and/or the GNU Lesser >- * General Public License, version 2.1, also as published by the Free >- * Software Foundation. >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. > * > * This program is distributed in the hope that it will be useful, > * but WITHOUT ANY WARRANTY; without even the implied warranty of > * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >- * GNU General Public License and the GNU Lesser General Public License >- * for more details. >+ * GNU General Public License for more details. > * > * You should have received a copy of the GNU General Public License >- * and the GNU Lesser General Public License along with this program; >- * if not, write to the Free Software Foundation, Inc., >- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. >+ * along with this program; if not, write to the Free Software Foundation, Inc., >+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA > */ > > package org.jboss.on.plugins.tomcat; >@@ -61,7 +57,7 @@ > */ > @SuppressWarnings("unchecked") > public class TomcatDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet { >- private final Log log = LogFactory.getLog(this.getClass()); >+ private static final Log LOG = LogFactory.getLog(TomcatDiscoveryComponent.class); > > /** > * Indicates the version information could not be determined. >@@ -111,28 +107,28 @@ > public static final String EWS_TOMCAT_5 = "tomcat5"; > > public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) { >- log.debug("Discovering Tomcat servers..."); >+ LOG.debug("Discovering Tomcat servers..."); > > Set<DiscoveredResourceDetails> resources = new HashSet<DiscoveredResourceDetails>(); > > // For each Tomcat process found in the context, create a resource details instance > List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses(); > for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) { >- if (log.isDebugEnabled()) { >- log.debug("Discovered potential Tomcat process: " + autoDiscoveryResult); >+ if (LOG.isDebugEnabled()) { >+ LOG.debug("Discovered potential Tomcat process: " + autoDiscoveryResult); > } > > try { > DiscoveredResourceDetails resource = parseTomcatProcess(context, autoDiscoveryResult); > if (resource != null) { >- if (log.isDebugEnabled()) { >- log.debug("Verified Tomcat process: " + autoDiscoveryResult); >+ if (LOG.isDebugEnabled()) { >+ LOG.debug("Verified Tomcat process: " + autoDiscoveryResult); > } > > resources.add(resource); > } > } catch (Exception e) { >- log.error("Error creating discovered resource for process: " + autoDiscoveryResult, e); >+ LOG.error("Error creating discovered resource for process: " + autoDiscoveryResult, e); > } > } > >@@ -146,7 +142,7 @@ > try { > catalinaHome = FileUtils.getCanonicalPath(catalinaHome); > } catch (Exception e) { >- log.warn("Failed to canonicalize catalina.home path [" + catalinaHome + "] - cause: " + e); >+ LOG.warn("Failed to canonicalize catalina.home path [" + catalinaHome + "] - cause: " + e); > // leave as is > } > File catalinaHomeDir = new File(catalinaHome); >@@ -156,7 +152,7 @@ > try { > catalinaBase = FileUtils.getCanonicalPath(catalinaBase); > } catch (Exception e) { >- log.warn("Failed to canonicalize catalina.base path [" + catalinaBase + "] - cause: " + e); >+ LOG.warn("Failed to canonicalize catalina.base path [" + catalinaBase + "] - cause: " + e); > // leave as is > } > >@@ -172,7 +168,7 @@ > // if the specified home dir does not exist locally assume this is a remote Tomcat server > // We can't determine version. Try to get the hostname from the connect url > if (!catalinaHomeDir.isDirectory()) { >- log.info("Manually added Tomcat Server directory does not exist locally. Assuming remote Tomcat Server: " >+ LOG.info("Manually added Tomcat Server directory does not exist locally. Assuming remote Tomcat Server: " > + catalinaHome); > > Matcher matcher = TOMCAT_MANAGER_URL_PATTERN.matcher(pluginConfig.getSimpleValue( >@@ -207,7 +203,9 @@ > > DiscoveredResourceDetails resource = new DiscoveredResourceDetails(discoveryContext.getResourceType(), > resourceKey, resourceName, version, productDescription, pluginConfig, null); >- log.debug("Verified manually-added Tomcat Resource with plugin config: " + pluginConfig); >+ if (LOG.isDebugEnabled()) { >+ LOG.debug("Verified manually-added Tomcat Resource with plugin config: " + pluginConfig); >+ } > > return resource; > } >@@ -228,21 +226,25 @@ > String[] commandLine = processInfo.getCommandLine(); > > if (null == processInfo.getExecutable()) { >- log.debug("Ignoring Tomcat instance (agent may not be owner) with following command line: " >+ if (LOG.isDebugEnabled()) { >+ LOG.debug("Ignoring Tomcat instance (agent may not be owner) with following command line: " >- + Arrays.toString(commandLine)); >+ + Arrays.toString(commandLine)); >+ } > return null; > } > > if (!isStandalone(commandLine) && !isWindows(context)) { >- log.debug("Ignoring embedded Tomcat instance (catalina.home not found) with following command line: " >+ if (LOG.isDebugEnabled()) { >+ LOG.debug("Ignoring embedded Tomcat instance (catalina.home not found) with following command line: " >- + Arrays.toString(commandLine)); >+ + Arrays.toString(commandLine)); >+ } > return null; > } > > String catalinaHome = determineCatalinaHome(commandLine); > > if (catalinaHome == null && isWindows(context)) { >- log.debug("catalina.home not found. Checking to see if this is an EWS installation."); >+ LOG.debug("catalina.home not found. Checking to see if this is an EWS installation."); > // On Windows EWS uses the tomcat5.exe, tomcat6.exe or Tomcat7.exe executables to start tomcat. They currently do > // not provide the command line args that we get with the normal start up scripts that are used to > // determine catalina.home. See https://bugzilla.redhat.com/show_bug.cgi?id=580931 for more information. >@@ -252,15 +254,15 @@ > } > > if (null == catalinaHome) { >- log.error("Ignoring Tomcat instance due to invalid setting of catalina.home in command line: " >+ LOG.error("Ignoring Tomcat instance due to invalid setting of catalina.home in command line: " >- + Arrays.toString(commandLine)); >+ + Arrays.toString(commandLine)); > return null; > } > > String catalinaBase = determineCatalinaBase(commandLine, catalinaHome); > if (null == catalinaBase) { >- log.error("Ignoring Tomcat instance due to invalid setting of catalina.base in command line: " >+ LOG.error("Ignoring Tomcat instance due to invalid setting of catalina.base in command line: " >- + Arrays.toString(commandLine)); >+ + Arrays.toString(commandLine)); > return null; > } > >@@ -313,7 +315,7 @@ > * Looks for tomcat home in the command line properties. Requires a full path for the catalina.home > * property. The path may be a symbolic link. > * >- * @param startup command line >+ * @param cmdLine startup command line > * > * @return A canonical form of the catalina home path set in the command line. Symbolic links > * are not resolved to ensure that we discover the same resource repeatedly for the same symlink >@@ -342,61 +344,78 @@ > } > > private String determineCatalinaHomeOnWindows(ProcessInfo processInfo) { >- File exePath = new File(processInfo.getName()); >+ File exeFile = new File(processInfo.getName()); >- >+ >- File parentDir = exePath.getParentFile(); >- if (parentDir == null) { //paranoia >+ File binDir = exeFile.getParentFile(); >+ if (binDir == null) { //paranoia >+ if (LOG.isDebugEnabled()) { >+ LOG.debug("Could not determine CatalinaHome: " + binDir + " does not exist"); >+ } > return null; > } > >- File ewsDir = parentDir.getParentFile(); >- if (ewsDir == null) { //paranoia >+ File rootDir = binDir.getParentFile(); >+ if (rootDir == null) { //paranoia >+ if (LOG.isDebugEnabled()) { >+ LOG.debug("Could not determine CatalinaHome: " + rootDir + " does not exist"); >+ } > return null; > } >- >+ >+ String tomcatExeName = exeFile.getName().toLowerCase(); >+ >+ //extract the major version from the exe name >+ int dotPos = tomcatExeName.lastIndexOf(".exe"); >+ if (dotPos < 1) { //paranoia, leaves out ".exe", too >+ if (LOG.isDebugEnabled()) { >+ LOG.debug("Could not determine CatalinaHome: cannot extract Tomcat major version from exe name [" >+ + tomcatExeName + "]"); >+ } >+ return null; >+ } >+ >+ String majorVersion = tomcatExeName.substring(dotPos - 1, dotPos); >+ >+ File ewsShareDir = new File(rootDir, "share"); >+ boolean isEws = ewsShareDir.isDirectory(); >+ if (isEws) { >- //EWS supports tomcat 5, 6 or 7 and starts them using the tomcat5.exe, >- //tomcat6.exe or Tomcat7.exe. The catalina homes we want for them are stored inside >- //$EWS_HOME/share/tomcat-<version>, where version differs. >- //EWS 1.0.1 uses tomcat 6.0.24, while EWS 1.0.2 uses tomcat 6.0.32 >- >- //To support this in a forwards compatiblish way, let's assume that >- //EWS is going to keep the practice of calling the main exes tomcat<MAJOR_VERSION>.exe >- //and that the catalina homes are going to get stored in >- //share/apache-tomcat-<MAJOR_VERSION>.x.y. >- >+ //EWS supports tomcat 5, 6 or 7 and starts them using the tomcat5.exe, >+ //tomcat6.exe or Tomcat7.exe. The catalina homes we want for them are stored inside >+ //$EWS_HOME/share/tomcat-<version>, where version differs. >+ //EWS 1.0.1 uses tomcat 6.0.24, while EWS 1.0.2 uses tomcat 6.0.32 >+ >+ //To support this in a forwards compatiblish way, let's assume that >+ //EWS is going to keep the practice of calling the main exes tomcat<MAJOR_VERSION>.exe >+ //and that the catalina homes are going to get stored in >+ //share/apache-tomcat-<MAJOR_VERSION>.x.y. >+ >- String tomcatExeName = exePath.getName().toLowerCase(); >- >- //extract the major version from the exe name >- int dotPos = tomcatExeName.lastIndexOf(".exe"); >- if (dotPos < 1) { //paranoia, leaves out ".exe", too >- return null; >- } >- >- String majorVersion = tomcatExeName.substring(dotPos - 1, dotPos); >- >- //now try to find the directory with the corresponding tomcat install >- //in the $EWS_HOME/share >- final String catalinaHomePrefix = "apache-tomcat-" + majorVersion; >+ //now try to find the directory with the corresponding tomcat install >+ //in the $EWS_HOME/share >+ final String catalinaHomePrefix = "apache-tomcat-" + majorVersion; >- File[] tomcatInstallDirs = new File(ewsDir, "share").listFiles(new FileFilter() { >+ File[] tomcatInstallDirs = ewsShareDir.listFiles(new FileFilter() { >- public boolean accept(File pathname) { >- return pathname.isDirectory() && pathname.getName().startsWith(catalinaHomePrefix); >- } >- }); >+ public boolean accept(File pathname) { >+ return pathname.isDirectory() && pathname.getName().startsWith(catalinaHomePrefix); >+ } >+ }); > >- if (tomcatInstallDirs.length == 0) { >- return null; >- } else if (tomcatInstallDirs.length > 1) { >+ if (tomcatInstallDirs.length == 0) { >+ return null; >+ } else if (tomcatInstallDirs.length > 1) { >- log.warn("Could not unambiguously determine the tomcat installation dir for EWS executable " + exePath.getAbsolutePath() + ". The candidates are: " + Arrays.asList(tomcatInstallDirs)); >+ LOG.warn("Could not unambiguously determine the tomcat installation dir for EWS executable " + exeFile.getAbsolutePath() + ". The candidates are: " + Arrays.asList(tomcatInstallDirs)); >- return null; >- } >- >- File tomcatDir = tomcatInstallDirs[0]; >+ return null; >+ } >+ >+ File tomcatDir = tomcatInstallDirs[0]; > >- if (tomcatDir.exists()) { >+ if (tomcatDir.exists()) { >- log.debug("Detected EWS installation. catalina.home found at " + tomcatDir.getAbsolutePath()); >+ if (LOG.isDebugEnabled()) { >+ LOG.debug("Detected EWS installation. catalina.home found at " + tomcatDir.getAbsolutePath()); >+ } >- return tomcatDir.getAbsolutePath(); >- } >+ return tomcatDir.getAbsolutePath(); >+ } >- >+ } else { >+ return rootDir.getAbsolutePath(); >+ } > return null; > } > >@@ -404,7 +423,7 @@ > * Looks for tomcat instance base in the command line properties. Requires a full path for the catalina.base, if > * specified. The path may be a symbolic link. > * >- * @param startup command line >+ * @param cmdLine startup command line > * > * @return A canonical form of the catalina base path if set in the command line. Symbolic links > * are not resolved to ensure that we discover the same resource repeatedly for the same symlink >@@ -464,7 +483,7 @@ > File versionScriptFile = new File(versionScriptFileName); > > if (!versionScriptFile.exists()) { >- log.warn("Version script file not found in expected location: " + versionScriptFile); >+ LOG.warn("Version script file not found in expected location: " + versionScriptFile); > return UNKNOWN_VERSION; > } > >@@ -482,8 +501,8 @@ > String version = getVersionFromVersionScriptOutput(versionOutput); > > if (UNKNOWN_VERSION.equals(version)) { >- log.warn("Failed to determine Tomcat Server Version Given:\nVersionInfo:" + versionOutput >+ LOG.warn("Failed to determine Tomcat Server Version Given:\nVersionInfo:" + versionOutput >- + "\ncatalinaHome: " + catalinaHome + "\nScript:" + versionScriptFileName + "\ntimeout=" + timeout); >+ + "\ncatalinaHome: " + catalinaHome + "\nScript:" + versionScriptFileName + "\ntimeout=" + timeout); > } > > return version; >@@ -552,7 +571,7 @@ > /** > * Check from the command line if this is an EWS tomcat > * >- * @param commandLine >+ * @param catalinaHome > * > * @return > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1035348
: 829784