"Johnny Kewl" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi Again LightBulb,
>
> In this good article
> http://www.javaworld.com/javaworld/jw-08-2005/jw-0801-jmx.html
> You will find an example JMX client, in SRC for talking directly to
> Tomcats JMXProxy
>
> One thing I dont see in the JMX interface, maybe it is there, is a way to
> start stop webapp through JMX.
>

In the MBeans tab in Jconsole, under WebModules navigate down to the MBean
of the webapp you want to stop, and in the Operations tab, choose "stop".

Assuming that you aren't using a SecurityManager (or that you have granted
permissions properly), then programatically you can do (assuming the default
values for Engine and that Host is "localhost", etc):

   MBeanServer
server=(MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
   ObjectName myApp = new
ObjectName("Catalina:j2eeType=WebModule,name=//localhost/myapp,J2EEApplication=none,J2EEServer=none");
   server.invoke(myApp, "stop", null, null);

Here, "Catalina" is the name of the enclosing Engine, "localhost" is the
name of the enclosing Host, and "/myapp" is the path attribute of the
webapp.  If you are running Tomcat within a J2EE Server (e.g. JBoss), then
you will have to find what it uses for the J2EE* values, or use the
queryMBeans method on the MBeanServer ("none" is what Tomcat standalone uses
by default).  Of course, if you are using JMX to embed Tomcat (e.g. JBoss),
then you use the same ON that you used to create the Context.


> Just want to say, this thread made me have a good look at JMX in Tomcat,
> an area I never bothered with before.... well done!... although I think
> making JMX clients is too much hassle, looking at Tomcat through a
> professional JMX client like JConsole is pure magic.
> You know if there was just a screen shot of Tomcat in the JConsole on the
> site, I think it would make people (like me) immediately see what a magic
> facility this is.
>
> The other thought I had was that I think if TC scrapped the logging tools
> it has now, in favour of an XML format, and a standard viewer, or any
> other format one wanted if they set up a bit of XSL, I think logs would
> look damn good in JConsole as well, would be easy to server through JMX,
> or just in a web page.

>From TC 5.5+, Tomcat doesn't handle logging (and nobody on [EMAIL PROTECTED] 
>has
expressed much interest in changing this :).  It is delegated to Juli or
log4j to do the actual logging.  For log4j, look at
http://logging.apache.org, for Juli, look at the documentation from your
Java vendor.

> The current  scheme seems to make them to hard to get at, which is
> actually a bit weird considering the things are sitting in a web
> server.... IMHO
>
> Have fun
>
>
>
> ----- Original Message ----- 
> From: "lightbulb432" <[EMAIL PROTECTED]>
> To: <users@tomcat.apache.org>
> Sent: Monday, June 25, 2007 9:04 PM
> Subject: Use JMX to manage applications
>
>
>>
>> How, from a web application deployed to Tomcat, can you customize the
>> behavior of your web application based on attributes specified in an
>> MBean?
>> The link http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html talks a
>> lot
>> about Ant tasks, but that's not really what I'm looking to do.
>>
>> How can you get programmatic access to MBeans? And how do you deploy
>> MBeans
>> to Tomcat?
>>
>> I'm pretty confused here...hopefully someone can clarify. Thanks.
>> -- 
>> View this message in context:
>> http://www.nabble.com/Use-JMX-to-manage-applications-tf3978363.html#a11293522
>> 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]
>
>






---------------------------------------------------------------------
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