tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Herman <e...@mysql.com>
Subject How to deploy a custom DynamicMBean
Date Tue, 10 Aug 2004 01:16:32 GMT
I'm looking for help from someone with some experience deploying
DynamicMBeans to Tomcat.

In short, my questions boil down to some very basic information gaps:
once we have a DynamicMBean,
(1) What do we need to add to the server.xml file?
(2) What other configuration file(s) need to be created/edited?
(3) What are the contents of those files?


Please feel free to tell me to "Read The Fine Manual" ... but I've had
some trouble locating meaningful docs. If the answers I seek are
documented somewhere, a pointer to those docs would be greatly
appreciated. Otherwise, I would be happy to put something together,
maybe a small how-to, once I have things working. I think a step-by-step
set of instructions around a concrete (if very simple) example would be
useful to others trying to do similar things.


Let me share what I've learned so far:

According to the "MBean Descriptor How To"
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/mbeans-descriptor-howto.html

Once we have an MBean, it looks like we need to create a
mbean-descriptor.xml and add it to the list of "descriptors" in the
ServerLifecycleListener tag. Something like:

  <Listener
   className="org.apache.catalina.mbeans.ServerLifecycleListener"
   descriptors="/scratch/mbean-descriptor.xml"
   debug="0"/>


I have tried this and get a very curious error:
org.xml.sax.SAXParseException: The processing instruction target
matching "[xX][mM][lL]" is not allowed. 

Should it be the "GlobalResourcesLifecycleListener" tag? Using that
seems to avoid the stack-trace, but then it doesn't look like the custom
DynamicMBean is being instantiated, so if this is correct, there's
something else missing.

I found one reference to someone else having similar confusion but was
not able to use the information to good advantage:

http://www.junlu.com/msg/93635.html

I didn't see a description the "Engine" tag suggested in this thread.


Assuming we are supposed to create "mbean-descriptor.xml" files (and the
SAXParseException can be over-come) ... are these files usually packaged
up in the jar file (with the MBean class files) deployed to server/lib?
That's where I've put it, for the moment, but I am not sure this is a
good practice. It doesn't seem right to package JMX Agent specific files
inside the jar; a different file is needed with JBoss, for instance.

I have not seen a good example of what this descriptor file is expected
to contain, especially for DynamicMBean where the attributes my not be
known at deployment time. If you know of an example, please post the
url.

Next the Descriptor How To suggests that "You may also add MBean
descriptions for custom components in
org.apache.catalina.mbeans.mbeans-descriptor.xml file." After some
searching, I think this file is normally only contained in the
catalina.jar file in the server/lib directory. This feels like messing
with the Tomcat internals. Ideally, I wouldn't want our new MBeans
exposed as part of Tomcat itself. So, I don't understand when or why we
should modify that file. 

To provide an DynamicMBean deployment example, I've attached a simple
"LightBulb" class to be managed, as well as a very naive DynamicMBean to
manage it. If we really had an application this simple, we probably
wouldn't be using a DynamicMBean, but I've tried to create something
simple enough to let us focus on the deployment issues.


Any input (kind or cruel) is welcome.

Cheers,
-- Eric

-- 
Eric Herman, Software Developer
MySQL AB, www.mysql.com
Office: +1 206 720 1724

Are you MySQL certified?  www.mysql.com/certification


Mime
View raw message