title: stop\start connector within my code
body: <p>I need to stop and then start the https connector programmatically.
  In tomcat 6 the following scrap of code works fine:</p>
  
  <pre><code>        final ObjectName objectNameQuery = new ObjectName("*:type=Connector,port=443,*"); 
          MBeanServer      mbeanServer = null;
          ObjectName       objectName  = null;
  
          for (final MBeanServer server : (List&lt;MBeanServer&gt;) MBeanServerFactory.findMBeanServer(null))
          {
              if (server.queryNames(objectNameQuery, null).size() &gt; 0)
              {
                  mbeanServer     = server;
                  objectName      = (ObjectName) server.queryNames(objectNameQuery, null).toArray()[0];
  
                  break;
              }
          }
  
          // now we restart the connector that we just found. We sleep a little, but I am
          // not actually sure 1) how long we should sleep for or 2) if sleeping is
          // necessary at all.
          if (mbeanServer != null)
          {
              mbeanServer.invoke(objectName, "stop", null, null);                
  
              Thread.sleep(waitForStopInSec * 1000);
  
              mbeanServer.invoke(objectName, "start", null, null);
  
              log.warn("https Connector was restarted");
          }
  </code></pre>
  
  <p>But in tomcat 7 (7.0.23) the connector does not stopped! So I invoked the destroy() method (right after invoking the stop() method) using this line of code:
  mbeanServer.invoke(objectName, "destroy", null, null);</p>
  
  <p>In this case the connector indeed stopped. But when I tried to start it, the connector did not start and I got this exception:</p>
  
  <pre><code>28/03/12 18:32:01 ERROR T:CommServerScheduler_Worker-1 TrustStoreRefreshJob.refreshHTTPSConnectors - failed to restart connector 
  javax.management.InstanceNotFoundException:    Catalina:type=Connector,port=443,address="/192.168.201.24"
       at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094)
       at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:833)
       at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
       at tool.security.TrustStoreRefreshJob.refreshHTTPSConnectors(TrustStoreRefreshJob.java:79)
       at tool.security.TrustStoreRefreshJob.executeJob(TrustStoreRefreshJob.java:32)
       at com.nextnine.common.scheduler.AbstractJobLogic.execute(AbstractJobLogic.java:47)
       at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
       at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
  </code></pre>
  
  <p>Any ideas of how I can stop and then start the connector in tomcat 7? Preferable in a graceful manner.
  Thanks in advance,
  Guy</p>