These patches fix various issues when the lokahi agent is controlling
tomcat. The jvm port for tomcat is not set to correctly control a jvm.
Adding a context to tomcat 5.5.x now only adds the context if it does not
already exist. Setting the environment for tomcat 4.0.4 now works correctly.
Getting the status of the contexts for 4.0.4 now calls the monitor command.

-Jeff


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD
and in Japan, as Banyu - direct contact information for affiliates is 
available at http://www.merck.com/contact/contacts.html) that may be 
confidential, proprietary copyrighted and/or legally privileged. It is 
intended solely for the use of the individual or entity named on this 
message. If you are not the intended recipient, and have received this 
message in error, please notify us immediately by reply e-mail and then 
delete it from your system.

------------------------------------------------------------------------------
Index: V:/src/java/org/apache/lokahi/core/agent/tomcat/HttpTomcat.java
===================================================================
--- V:/src/java/org/apache/lokahi/core/agent/tomcat/HttpTomcat.java     
(revision 433233)
+++ V:/src/java/org/apache/lokahi/core/agent/tomcat/HttpTomcat.java     
(working copy)
@@ -29,7 +29,6 @@
 import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.regex.Pattern;
 
 /**
  * @author Stephen Toback
@@ -50,10 +49,19 @@
   private HashMap<String, String> env = new HashMap<String, String>();
 
   public void setEnvironment(String s) {
-    while (!"".equals(s.trim())) {
-      env.put(s.substring(0, s.indexOf('=') - 1), s.substring(s.indexOf('='), 
s.indexOf(';') - 1));
-      s = s.substring(s.indexOf(';'));
-    }
+         if (s != null) {
+                 try {
+                         while (!"".equals(s.trim())) {
+                                 env.put(s.substring(0, s.indexOf('=')), 
s.substring(s.indexOf('=') + 1, s.indexOf(';')));
+                                 s = s.substring(s.indexOf(';') + 1);
+                         }
+                 }
+                 catch (Exception e) {
+                         if (logger.isInfoEnabled()) {
+                                 logger.info("BAD Exception: " + 
e.getMessage());
+                         }
+                 }
+         } 
   }
 
   public int getPk() {
@@ -120,6 +128,13 @@
     this.javaOptions = javaOptions;
   }
 
+  public static HttpTomcat discover(int httpPort) {
+         HttpTomcat t = new HttpTomcat();
+         if (logger.isInfoEnabled()) logger.info("Creating new HttpTomcat...");
+         t.setHttpPort(httpPort);
+         return t;
+  }
+  
   public boolean startContext(String context) {
     return httpRequest("start&path=" + 
checkContextName(context)).startsWith("OK");
   }
@@ -170,7 +185,7 @@
   }
 
   public String getStatusOfContext(String context) {
-    return this.getSessions(context);
+         return httpRequest("monitor");
   }
 
   public Map<String, String> getEnv() {
Index: V:/src/java/org/apache/lokahi/core/agent/jmx/JMXTomcat.java
===================================================================
--- V:/src/java/org/apache/lokahi/core/agent/jmx/JMXTomcat.java (revision 
433233)
+++ V:/src/java/org/apache/lokahi/core/agent/jmx/JMXTomcat.java (working copy)
@@ -208,7 +208,7 @@
   public boolean addContext(String path, String docBase) {
     boolean ret = false;
     try {
-      if (!this.getContexts().keySet().contains(checkContextName(path))) 
//TODO fix this line
+      if (!this.getContexts().keySet().contains("//localhost" + 
checkContextName(path))) //TODO fix this line
         ret = this.invokeVoidMethod(this.getCatalinaMBean(), 
"createStandardContext", new Object[]{this.getHost().toString(), 
checkContextName(path), docBase, false, false, false, false}, new 
String[]{"java.lang.String", "java.lang.String", "java.lang.String", "boolean", 
"boolean", "boolean", "boolean"});
     } catch (MalformedObjectNameException e) {
       if (logger.isInfoEnabled()) {
Index: V:/src/java/org/apache/lokahi/core/agent/util/ProcessFactory.java
===================================================================
--- V:/src/java/org/apache/lokahi/core/agent/util/ProcessFactory.java   
(revision 433233)
+++ V:/src/java/org/apache/lokahi/core/agent/util/ProcessFactory.java   
(working copy)
@@ -105,16 +105,16 @@
     AgentTomcat t;
     if ("yes".equalsIgnoreCase(tomcatProps.getProperty(port + 
".tomcat.param.jmx"))) {
       t = JMXTomcat.discover(port);
-    } else {
-      t = new HttpTomcat();
+    } else { 
+      t = HttpTomcat.discover(port);
     }
+    
     t.setName(tomcatProps.getProperty(port + ".tomcat.name"));
     t.setJavaOptions(tomcatProps.getProperty(port + ".java.param.options"));
     t.setEnvironment(tomcatProps.getProperty(port + ".java.param.env"));
     t.setJavaHome(tomcatProps.getProperty(port + ".java.home"));
     t.setStartClass(tomcatProps.getProperty(port + ".tomcat.startclass"));
     t.setStandardOutLog(tomcatProps.getProperty(port + 
".java.param.standard.out.log"));
-
     return t;
   }
 

Reply via email to