Re: Trouble registering an MBean with mbeans-descriptors.xml

2014-03-21 Thread Christopher Schultz
-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 mbeans 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 

Re: Trouble registering an MBean with mbeans-descriptors.xml

2014-03-20 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

All,

On 3/19/14, 12:24 PM, Christopher Schultz wrote:
 All,
 
 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:
 
 ?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
 
 attribute name=className description=Fully qualified class name
 of the managed object type=java.lang.String writeable=false/
 
 operation name=getProcessingTime description=Gets the total
 number of milliseconds spent processing requests. impact=INFO 
 returnType=long /operation
 
 operation name=getRequestCount description=Gets the total
 number of requests processed. impact=INFO returnType=long 
 /operation
 
 operation name=resetCounters description=Resets all counters. 
 impact=ACTION returnType=void /operation /mbean 
 /mbeans-descriptors
 
 I realize that two of the operations should probably be
 attributes instead, but it was about the time I changed from
 operation to attribute that things stopped working, so I
 rolled-back my changes a bit to back-track.
 
 Here's the contents of my mbean-example.jar file:
 
 Archive:  mbeans-example.jar Length   MethodSize  Ratio   Date
 Time   CRC-32Name   --  --- -      
 -- 0  Stored0   0%  03-19-14 12:19  
 META-INF/ 103  Defl:N   90  13%  03-19-14 12:19  d2b59077 
 META-INF/MANIFEST.MF 0  Stored0   0%  03-19-14 11:57
   filters/ 0  Stored0   0%  03-19-14 11:57
   mbean/ 2387  Defl:N 1196  50%  03-19-14 12:19
 2d7e415d filters/RequestStatsFilter.class 714  Defl:N  436  39%
 03-19-14 11:57  7bdf9245 mbean/RequestStats.class 165  Defl:N
 138  16%  03-19-14 11:57  041e1c7f mbean/RequestStatsMBean.class 
 1058  Defl:N  390  63%  03-19-14 12:19  ba6ca9b6 
 mbean/mbeans-descriptors.xml
 
 I can't see to find the text mbean.Request anywhere in the log 
 files. I've become desperate and set org.apache.tomcat.level=ALL
 and org.apache.catalina.level=ALL to see if I can find anything.

Setting the log level to ALL shows no attempt to even locate my
mbeans-descriptors.xml file. Any pointers for where I can start looking?

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTKveiAAoJEBzwKT+lPKRYd+MQAJ/9UfsMatOnKlvsuJV+M4Cb
nJdYj9o7Na7GLjsP1nYTaCv95vqj+IlFhsCGZ4GH4VCp4ffBPBRD7kijcn+VUORn
pzfzbDP4qYLzM03SqTDNsx0Xk3mafd7ZppXqm+tYYy6h5IJNq+v+nN3K9SAThYhb
OcD7FWAeCc0CdBQT57VQesRQggMzCg+bVmFNBLC8dEwQ7BWx1Lh9PNybASQN7jjG
26KmmpGExOnj7pVHlBCS9bkuEuUOR1R2B4lsKTLNniaPW9AznKNdgziPxa7FhXCr
FWauW/yb0LmRFvSnHDhN+zTzHwcOK/qnKTf2dR3J2alsBPJs37e93q0jo+o/f4+q
rurDaSsYCkVckhhaGW4kiijMiXgdp2o6F0mMpId3AwGa/jqbQdfo8KqoQLz1Wcuq
D86fGX/WJdwwuZorkAvCBCP1ttU7xhFwbzBVE8VDHf+nDiA4Ggp1KBFQ3o7PRYWu
QD/7jqOiVNkiTBZomWIlgn5J2K8M8wgNlw1nRiSmLc64WFDRFGFNN3y4Va9qwX0F
6lIqtF01/X5iI2i4LsjKrfWK40OuVuqMyze5wJziLj6x5FTnjiAHie5afUQn3Jwb
o+W+5L9qL5WKQMEHS+yO/O/u/8McFg9JTDXE7hHOlGNJQM2AMmUWp5k+toxPCewL
9CJt+D/n+N2LPkJ/cege
=H4+B
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Trouble registering an MBean with mbeans-descriptors.xml

2014-03-20 Thread Konstantin Kolinko
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?

2. How exactly are you registering your MBean?

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

3. Maybe run with a debugger?

 ?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 mbeans 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()).

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.

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

Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Trouble registering an MBean with mbeans-descriptors.xml

2014-03-19 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

All,

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:

?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

attribute name=className
   description=Fully qualified class name of the managed
object
   type=java.lang.String
   writeable=false/

operation name=getProcessingTime
   description=Gets the total number of milliseconds
spent processing requests.
   impact=INFO
   returnType=long
/operation

operation name=getRequestCount
   description=Gets the total number of requests processed.
   impact=INFO
   returnType=long
/operation

operation name=resetCounters
   description=Resets all counters.
   impact=ACTION
   returnType=void
/operation
  /mbean
/mbeans-descriptors

I realize that two of the operations should probably be attributes
instead, but it was about the time I changed from operation to
attribute that things stopped working, so I rolled-back my changes a
bit to back-track.

Here's the contents of my mbean-example.jar file:

Archive:  mbeans-example.jar
 Length   MethodSize  Ratio   Date   Time   CRC-32Name
-   --  --- -         --
   0  Stored0   0%  03-19-14 12:19    META-INF/
 103  Defl:N   90  13%  03-19-14 12:19  d2b59077
META-INF/MANIFEST.MF
   0  Stored0   0%  03-19-14 11:57    filters/
   0  Stored0   0%  03-19-14 11:57    mbean/
2387  Defl:N 1196  50%  03-19-14 12:19  2d7e415d
filters/RequestStatsFilter.class
 714  Defl:N  436  39%  03-19-14 11:57  7bdf9245
mbean/RequestStats.class
 165  Defl:N  138  16%  03-19-14 11:57  041e1c7f
mbean/RequestStatsMBean.class
1058  Defl:N  390  63%  03-19-14 12:19  ba6ca9b6
mbean/mbeans-descriptors.xml

I can't see to find the text mbean.Request anywhere in the log
files. I've become desperate and set org.apache.tomcat.level=ALL and
org.apache.catalina.level=ALL to see if I can find anything.

Can anyone shed some light on why my mbeans-descriptors.xml file isn't
being loaded -- or even looked-for?

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTKcTAAAoJEBzwKT+lPKRYPCgP/RCphdm99mvtPCKnca7pDebU
rTY/9rg8GnUsvIaZk5n5AH4yDIp4rVQUtNHUdX7UniAgkMkMzj78djC2a4rlOGpg
c9n872banvQzPnOf5zEC0/WfKQsW/qD0JeO1+mROTVRuPO119n7K2p6YxZxTD870
0qN9IlE1qd5q0mOI7gqP0YS6qS77OaYUyb8IFfiyTyuKzuHJyz+SodR7RasRQH2y
ABUaKbyRzH1kj7WIOgBFVBiNfGUF9XPHhrqm+gEDGuX3+0oQRSay+B98mSw0FsEB
Sj9vjKtYfKMnT4amvC43Df2yqSN+qyeDx/nyGQVFif55XPbe/Zw0LztHBLjmlKiI
jl8EQPfzhrFO7V2tC1WZkjz2+bWDrz9YJJ18s6NSpb+zd8HCnDnRh3WvD1+3+yP5
fPV4IgH3D1MNhPuY6ek5v7Pl6LZ4914+h3zesYeZADURCtxaIatoBltnoCe0wuh7
Bh2qzOklYrlGpQW2DKjGmydJwjq+MdYVimzCs/ZuovULJLxFOTYRUsy5I2UYedGh
qZF4hDkrZUtmDUUk+fZt0K3yO4ARcwNzMRT0bCWC4ue9+yqDfX+cwBCuv84zdZlY
65WVKgW9xF7SaHh6mb63D2Mw1vgn6Y3350XoE8kABbfj84zcJzCr8BYdbtKO9GG8
32b0D79cvbvM1ki8NjRA
=1oNm
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: