Actually, in my case, stopping a Host should work since I only have one app
assigned to each Host:

<Server>
  <Service>
    <Engine>
      <Host name="www.myapp.com" ... >
        <Context path="" docBase="myapp" .../>
      </Host>
      <Host name="www.myAdminapp.com" ... >
        <Context path="admin" docBase="myAdminapp" ... />
      </Host>
    </Engine>
  </Service>
</Server>

With my code I successfully stop the 'myapp' 'Host', thus killing the
'myapp' Context. But calling start() don't do jack. :(

But I take your meaning, it would be better to stop the Context. The trouble
is I can't seem to find a Context MBean. I've been messing around with Lamda
Probe, which is a lot like Tomcat's Manager webapp but better. Its
shortcoming however is that it seems to only let you administer the Tomcat
instance in which it is deployed, thus it's not useful for what I want to
do, namely use JMX to manage a remote Tomcat.

I will look at MC4J ... anything to get this over with, my brain is frying
from the effort ...

Cheers,
Bob


Johnny Kewl wrote:
> 
> 
> Nice Bob.... I actually think you have cracked the JMX client stuff....
> I dont think that is the right operation, it does work, but if you 
> stop/start the whole host, every webapp on the host will stop and start.
> 
> What we actually need is the context with those operations, and there
> doesnt 
> seem to be one.
> There is another one under host, called deployer, it sounds promising but
> I 
> couldnt make sense of it.
> 
> Anyway.... it may sound like I have wriiten all the code, I havnt, just 
> wanted to tell you to get MC4J, if you havnt got it already.
> It will show you all the MBeans and let you play with the operations, and 
> properties... save you struggling with the code.
> 
> I couldnt figure out how to stop/start a web-app (context).... maybe you 
> will crack it.
> 
> Good Luck
> 
> 
> ----- Original Message ----- 
> From: "syg6" <[EMAIL PROTECTED]>
> To: <users@tomcat.apache.org>
> Sent: Wednesday, June 27, 2007 1:28 PM
> Subject: Re: Programmatically stop/start context (webapp)
> 
> 
>>
>> Well, I've made some progress.
>>
>> Basically, you follow all the steps to get Tomcat to load JMX support,
>> essentially editing your catalina.sh.
>>
>> Then you connect to Tomcat's JMX MBean server, choose a domain, choose an
>> MBean, choose an Operation, and execute it. The following code, mostly
>> pilfered, does all this:
>>
>> JMXServiceURL url = new
>> JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:6666/jmxrmi");
>>
>> Map map = new HashMap();
>> String[] credentials = new String[] { "monitorRole" , "QED" };
>> map.put("jmx.remote.credentials", credentials);
>>
>> JMXConnector conn = JMXConnectorFactory.connect(url, map);
>> MBeanServerConnection mbsc = conn.getMBeanServerConnection();
>> ObjectName objName = new
>> ObjectName("Catalina:host=www.myapp.com,type=Host");
>> MBeanInfo mbeanInfo = mbsc.getMBeanInfo(objName);
>>
>> Object[] params = new Object[0];
>> String[] signatures = new String[0];
>> mbsc.invoke(objName, action, params, signatures);
>>
>> conn.close();
>>
>> NOTES ON BOLD TEXT :
>>
>> 1. 6666 is the port I told Tomcat to listen on in my catalina.sh file.
>> The
>> params are the following:
>> CATALINA_OPTS="$CATALINA_OPTS ""-Dcom.sun.management.jmxremote
>> -Dcom.sun.management.jmxremote.port=6666
>> -Dcom.sun.management.jmxremote.ssl=false
>> -Dcom.sun.management.jmxremote.authenticate=false"
>>
>> 2. The host, www.myapp.com, is the name of my virtual host in my 
>> server.xml
>> file:
>> <Server>
>>  <Service>
>>    <Engine>
>>      <Host name="www.myapp.com" ...>
>>
>> If you want a list of operations exposed by an MBean just use the 
>> following
>> code:
>>
>> MBeanOperationInfo[] ops = mbeanInfo.getOperations();
>> for (int i = 0; i < ops.length; i++)
>> {
>>  MBeanOperationInfo op = ops[i];
>>  System.out.println("op: " + op.getName() + " , desc: " +
>> op.getDescription());
>> }
>>
>> The MBean I have chosen, "Catalina:host=www.myapp.com,type=Host", has
>> start(), stop(), init() and a couple other operations (methods).
>>
>> All is ok when I stop an already started Host. But when I then call 
>> start()
>> or init(), it does nothing, throws no Exception.
>>
>> What could I be doing wrong? I posted this question on the Java JMX forum 
>> as
>> well ...
>>
>> Many thanks!
>> Bob
>>
>>
>> -- 
>> View this message in context: 
>> http://www.nabble.com/Programmatically-stop-start-context-%28webapp%29-tf3975317.html#a11322642
>> Sent from the Tomcat - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>> 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Programmatically-stop-start-context-%28webapp%29-tf3975317.html#a11326854
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to