-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Konstantin,
On 3/20/14, 6:38 PM, Konstantin Kolinko wrote: > 2014-03-19 20:24 GMT+04:00 Christopher Schultz > <ch...@christopherschultz.net>: >> >> 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: import javax.management.MBeanServer; ... 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()). +1 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 implementation. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJTLINbAAoJEBzwKT+lPKRYgIsQAJ/HXcznaL+P/SqUEGeN0vsO esWi7O9m3LoCRze4vMsYPZ9RfsWzq/Bu4kxGg2Z0oVUnXniGF2sJytZGjwu6URcj iSLFGvBon4vGqoy3f6K2BPlo+34GvTdX7L4p0hlTby+Db/7uGxpiK94P4vSMPVgJ 4HJUS9HkIYdM40I/tvyy3YnWxGCY2mXUcPSgyrCuHzjWEcD46BRY8gUFyFyFbRUh Lqd/qNY9ASBf2xY6M4Jr7i0kjO58sjc6Gfltb9nvAmnDDjf657kZXAj4qgY/GXKG 4sLgjvhJb1ZHYATgw/bkwSuPkRpIilv9gqpE7+OT8XMN3wXrFD/KPvWThMj6QxT9 xrVmoQbCTuCNoOp6ncHWa7ZSsueMbKPx1hNeNVusHD+vuJinGmb4sTuONYc4oCCU 7nL95I2/9pjA8tGVCiuXxKUc7e4eR6/7ZkJ3ag7uo8MnvGIVQX4pDJT1lImJky2T TmHujlmhkO7KDqxSqtFhoBuD9ChJPwK4Qa3PjIWvj+8AYXrlOZQMcDaE2we7QsbN w8yTaSSxWypIe/gQyZu22A5a7NHs5JEI9YytvVdBYZUKBGT+GSvc8Oq8CYr8hRxP +1Dzxun0G9QKd/L/VNnZ213WECC+a+LLSBWWoazM6qstPA/wjJ2s+IR7DhhMpr6s xxCKscJgPjbkW+4kiZSO =3bzv -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org