User: oberg   
  Date: 00/11/02 11:10:37

  Modified:    src/main/org/jboss/tomcat TomcatService.java
  Log:
  Fixed context classloader issue
  
  Revision  Changes    Path
  1.5       +38 -38    jboss/src/main/org/jboss/tomcat/TomcatService.java
  
  Index: TomcatService.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/tomcat/TomcatService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TomcatService.java        2000/08/18 03:21:12     1.4
  +++ TomcatService.java        2000/11/02 19:10:37     1.5
  @@ -25,7 +25,7 @@
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.4 $
  + *   @version $Revision: 1.5 $
    */
   public class TomcatService
      extends ServiceMBeanSupport
  @@ -61,46 +61,46 @@
         throws Exception
      {
         final Log log = this.log;
  -      runner = new Thread(new Runnable()
  +      
  +      // Save CL since Tomcat does not reset it properly when it is done
  +      ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
  +      
  +      try
         {
  -         public void run()
  +         Class tomcatClass;
  +         
  +         log.log("Testing if Tomcat is present....");
  +         try{
  +             tomcatClass = Class.forName("org.apache.tomcat.startup.Tomcat");
  +             log.log("OK");
  +         }catch(Exception e)
            {
  -            try
  -            {
  -               Class tomcatClass;
  -               
  -               log.log("Testing if Tomcat is present....");
  -               try{
  -                   tomcatClass = Class.forName("org.apache.tomcat.startup.Tomcat");
  -                   log.log("OK");
  -               }catch(Exception e)
  -               {
  -                    log.log("failed");
  -                    log.log("Tomcat wasn't found. Be sure to have your CLASSPATH 
correctly set");
  -                    //Logger.exception(e);
  -                    return;
  -               } 
  -               
  -               Class tomcatArgsClasses[] = new Class[1];
  -               String args[] = new String[0];
  -               tomcatArgsClasses[0] = args.getClass();
  -               Method mainMethod = tomcatClass.getMethod("main", tomcatArgsClasses);
  -               
  -               Object tomcatArgs[] = new Object[1];
  -               tomcatArgs[0] = args;
  -               
  -               Logger.log("Starting Tomcat...");
  -               mainMethod.invoke(null,tomcatArgs); 
  -               
  -            } catch (Exception e)
  -            {
  -               log.error("Tomcat failed");
  -               log.exception(e);
  -            }
  -         }
  -      });
  +              log.log("failed");
  +              log.log("Tomcat wasn't found. Be sure to have your CLASSPATH 
correctly set");
  +              //Logger.exception(e);
  +              return;
  +         } 
  +         
  +         Class tomcatArgsClasses[] = new Class[1];
  +         String args[] = new String[0];
  +         tomcatArgsClasses[0] = args.getClass();
  +         Method mainMethod = tomcatClass.getMethod("main", tomcatArgsClasses);
  +         
  +         Object tomcatArgs[] = new Object[1];
  +         tomcatArgs[0] = args;
  +         
  +         Logger.log("Starting Tomcat...");
  +         mainMethod.invoke(null,tomcatArgs); 
  +         
  +      } catch (Exception e)
  +      {
  +         log.error("Tomcat failed");
  +         log.exception(e);
  +      } finally
  +      {
  +         Thread.currentThread().setContextClassLoader(oldCl);
  +      } 
         
  -      runner.start();
      }
      
      public void stopService()
  
  
  

Reply via email to