tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Trouble registering an MBean with mbeans-descriptors.xml
Date Fri, 21 Mar 2014 18:22:19 GMT
Hash: SHA256


On 3/20/14, 6:38 PM, Konstantin Kolinko wrote:
> 2014-03-19 20:24 GMT+04:00 Christopher Schultz
> <>:
>> I'm trying to write my own MBean, and I have it working: the bean
>> is registered and I can browse it using jconsole, etc., call
>> methods, etc.
>> At one point during the process, I believe I had the 
>> beans-descriptors.xml file actually being loaded, so that my 
>> customized descriptions of attributes and methods were being
>> shown in jconsole.
>> At some point, I changed something and they are no longer showing
>> up. It looks like I'm getting an introspected MBean description
>> instead of the declared one I want. All the attributes for
>> example are described as "Attribute exposed for management".
>> I've set org.apache.tomcat.util.modeler.level=ALL and the same
>> for the Console logger, so I'm getting a steady stream of output
>> from the modeler package, including a whole bunch of messages
>> like this:
>> FINER [main]
>> org.apache.tomcat.util.modeler.Registry.loadDescriptors Finding
>> descriptor org/apache/catalina/authenticator
>> Great. What I don't see is a similar message for my own MBean.
>> It doesn't look like Tomcat is ever trying to load the 
>> mbeans-descriptors.xml file for my MBean.
>> Here's what I've got:
>> 0. Tomcat 8.0-trunk 1. A JAR file in CATALINA_BASE/lib containing
>> my MBean interface, class, and mbeans-descriptors.xml, all in the
>> same package (imaginatively called "mbeans"), and a Filter class
>> that creates the bean and registers it with the MBean server. 2.
>> The Tomcat "examples" webapp, with modifications to
>> WEB-INF/web.xml to load the aforementioned Filter.
>> Here's the whole mbeans-descriptors.xml file:
>> <....>
> 1. Does your web application start, at all? Does you filter start?

Yes to both.

> 2. How exactly are you registering your MBean?

This code in the Filter's init() method:


  MBeanServer server = getServer();
      server.registerMBean(_stats, new
ObjectName("Example:RequestStats=RequestStats,name=" + filterName;));

> Are you using Modeler API for that?
> (Registry.registerComponent(....))

No, I'm using JMX API.

Maybe I wasn't clear enough initially: every single thing is working
correctly: the Filter runs, registers the bean, and collects data
properly. I can see everything in jconsole, etc. The only thing that
is missing is all the descriptions for the operations and attributes
that I have put into my mbeans-descriptors.xml file. All the
descriptions say "(Operation|Attribute) exposed for management".

> 3. Maybe run with a debugger?

Yes, this is the conclusion I'm coming to. I've never run Tomcat under
the Eclipse debugger before. Time to learn.

>> <?xml version="1.0"?>
>> <mbeans-descriptors> <mbean name="RequestStats" 
>> className="org.apache.catalina.mbeans.ClassNameMBean" 
>> description="Server statistics and configuration" 
>> domain="Catalina" type="mbeans.RequestStats">
> 4. I see that many <mbean>s have a "group" attribute. Yours does
> not have one.
> (Actually it seems that this attribute is optional and is ignored. 
> There are no calls to ManagedBean.getGroup() except in 
> ManagedBean.toString()).


I'm writing an example MBean for ApacheCon and I didn't want to
include things that weren't absolutely necessary.

> 5. I hope that you do not have the second copy of your jar inside
> of your webapp. So that it shadows the one in the lib/ directory.

I do not in fact have a second copy of that JAR in my web application.
I'm using Tomcat's "examples" web application with only a modified
web.xml to deploy the Filter. The Filter class itself is packaged in
the JAR along with the MBean and exists only in CATALINA_BASE/lib.

> 6. Apparently many mbean descriptors are pre-loaded when Tomcat
> starts - in o.a.c.mbeans.MBeanUtils.createRegistry()

I could swear that it was working when I started with my initial

- -chris
Version: GnuPG v1
Comment: GPGTools -
Comment: Using GnuPG with Thunderbird -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message