Re: Need help with Tomcat MBean support

2008-09-08 Thread Steve Cohen
I sent this in over the weekend and didn't get a response so let me try 
this again a bit differently.


The Sun JDK 5.0 JMX tutorial shows that it is possible and simple to 
create JMX client and JMX server in separate JVMs and have them talk to 
each other.


The first article cited by Mr. Hall shows that it is possible and simple 
to create a JMX server running inside Tomcat and talk to it through 
tools such as MC4J and JManage.


I need to combine the Server side approach recommended by the article 
(JMX server within Tomcat webapp) with the Client side approach 
recommended by Sun in their tutorial. 

So far my client-side app can connect to the MBean server inside of 
Tomcat and talk to it but it fails to create the MBean needed to 
interact with the server because of ClassLoader issues.


Questions: 
1. Is this even possible?  It would seem to be so since MC4J and JManage 
know how to do it.

2. If so, how do I surmount these ClassLoader issues?

Thank you very much.

Steve Cohen wrote:
Okay using approach of first article.  The MBean server is correctly 
initialized and everything on the server side looks good.


Now we come to the client side.  The first article assumes you are 
just going to connect using a tool such as MC4J or JManage (monitoring 
tools).


That is not my use case.  I want to write a command-line client that 
can talk to the MBean (which is inside of Tomcat) and invoke an 
operation on the MBean.


I use the Client.java sample from the Sun tutorial as a starting point.

I am able to connect to the server, and get a list of MBeans, but I 
fail when trying to call createMBean().  I am using the simple 
two-parameter version of createMBean() and it always fails with


javax.management.ReflectionException: The MBean class could not be 
loaded by the default loader repository


It seems pretty clear that my client needs to use one of the other 
versions of createMBean(), one that specifies some other Class Loader 
but I have no clue what I should be using for that.



H. Hall wrote:

Steve Cohen wrote:

Let me ask my question a little more directly:

Does the presence of a descriptor cause instantiation of an instance 
of an MBean
or do I have to write code to create a server-side instance of my 
MBean and if so, where should this code reside
or is there some configuration artifact that causes this 
instantiation to happen?





Why don't you take a look at these two articles:
http://today.java.net/pub/a/today/2005/11/15/using-jmx-to-manage-web-applications.html?page=1 



http://marxsoftware.blogspot.com/2008/07/jmx-model-mbeans-with-apache-commons.html 



If you use the NetBeans IDE you might be interested in the JMX plugin 
for NB. Here is a link to a tutorial Getting Started with JMX 
Monitoring in NetBeans IDE 6.0


http://www.netbeans.org/kb/60/java/jmx-getstart.html

cheers,
HH





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



Re: Need help with Tomcat MBean support - SOLVED

2008-09-08 Thread Steve Cohen

Finally figured out how to do what I wanted to do.

Turns out I had no need at all of creating an MBean in my client.  Duh!  
I never understood why I needed to do that but that is what the sample did.


All I needed to do was call the MBeanServerConnection.invoke() method 
with a suitable object name and other params to invoke the operation on 
the MBean I had ALREADY instantiated on my server. 

That's what you get for slavishly following example code instead of 
thinking.


By the way I found this out by staring at the Ant examples on 
http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html.  I finally 
realized that if Ant can invoke an operation, so could a non-Ant 
executable.  From there a simple peek at the jmx ant task source code 
showed me what I needed to do.  Voila!


Gotta love open source - once you figure out where to look.

Thank you to all who helped.



Steve Cohen wrote:
I sent this in over the weekend and didn't get a response so let me 
try this again a bit differently.


The Sun JDK 5.0 JMX tutorial shows that it is possible and simple to 
create JMX client and JMX server in separate JVMs and have them talk 
to each other.


The first article cited by Mr. Hall shows that it is possible and 
simple to create a JMX server running inside Tomcat and talk to it 
through tools such as MC4J and JManage.


I need to combine the Server side approach recommended by the article 
(JMX server within Tomcat webapp) with the Client side approach 
recommended by Sun in their tutorial.
So far my client-side app can connect to the MBean server inside of 
Tomcat and talk to it but it fails to create the MBean needed to 
interact with the server because of ClassLoader issues.


Questions: 1. Is this even possible?  It would seem to be so since 
MC4J and JManage know how to do it.

2. If so, how do I surmount these ClassLoader issues?

Thank you very much.

Steve Cohen wrote:
Okay using approach of first article.  The MBean server is correctly 
initialized and everything on the server side looks good.


Now we come to the client side.  The first article assumes you are 
just going to connect using a tool such as MC4J or JManage 
(monitoring tools).


That is not my use case.  I want to write a command-line client that 
can talk to the MBean (which is inside of Tomcat) and invoke an 
operation on the MBean.


I use the Client.java sample from the Sun tutorial as a starting point.

I am able to connect to the server, and get a list of MBeans, but I 
fail when trying to call createMBean().  I am using the simple 
two-parameter version of createMBean() and it always fails with


javax.management.ReflectionException: The MBean class could not be 
loaded by the default loader repository


It seems pretty clear that my client needs to use one of the other 
versions of createMBean(), one that specifies some other Class Loader 
but I have no clue what I should be using for that.



H. Hall wrote:

Steve Cohen wrote:

Let me ask my question a little more directly:

Does the presence of a descriptor cause instantiation of an 
instance of an MBean
or do I have to write code to create a server-side instance of my 
MBean and if so, where should this code reside
or is there some configuration artifact that causes this 
instantiation to happen?





Why don't you take a look at these two articles:
http://today.java.net/pub/a/today/2005/11/15/using-jmx-to-manage-web-applications.html?page=1 



http://marxsoftware.blogspot.com/2008/07/jmx-model-mbeans-with-apache-commons.html 



If you use the NetBeans IDE you might be interested in the JMX 
plugin for NB. Here is a link to a tutorial Getting Started with 
JMX Monitoring in NetBeans IDE 6.0


http://www.netbeans.org/kb/60/java/jmx-getstart.html

cheers,
HH





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



Re: Need help with Tomcat MBean support

2008-09-06 Thread Steve Cohen
Okay using approach of first article.  The MBean server is correctly 
initialized and everything on the server side looks good.


Now we come to the client side.  The first article assumes you are just 
going to connect using a tool such as MC4J or JManage (monitoring tools).


That is not my use case.  I want to write a command-line client that can 
talk to the MBean (which is inside of Tomcat) and invoke an operation on 
the MBean.


I use the Client.java sample from the Sun tutorial as a starting point.

I am able to connect to the server, and get a list of MBeans, but I fail 
when trying to call createMBean().  I am using the simple two-parameter 
version of createMBean() and it always fails with


javax.management.ReflectionException: The MBean class could not be 
loaded by the default loader repository


It seems pretty clear that my client needs to use one of the other 
versions of createMBean(), one that specifies some other Class Loader 
but I have no clue what I should be using for that. 




H. Hall wrote:

Steve Cohen wrote:

Let me ask my question a little more directly:

Does the presence of a descriptor cause instantiation of an instance 
of an MBean
or do I have to write code to create a server-side instance of my 
MBean and if so, where should this code reside
or is there some configuration artifact that causes this 
instantiation to happen?





Why don't you take a look at these two articles:
http://today.java.net/pub/a/today/2005/11/15/using-jmx-to-manage-web-applications.html?page=1 



http://marxsoftware.blogspot.com/2008/07/jmx-model-mbeans-with-apache-commons.html 



If you use the NetBeans IDE you might be interested in the JMX plugin 
for NB. Here is a link to a tutorial Getting Started with JMX 
Monitoring in NetBeans IDE 6.0


http://www.netbeans.org/kb/60/java/jmx-getstart.html

cheers,
HH





-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Tomcat MBean support

2008-09-05 Thread H. Hall

Steve Cohen wrote:

Let me ask my question a little more directly:

Does the presence of a descriptor cause instantiation of an instance 
of an MBean
or do I have to write code to create a server-side instance of my 
MBean and if so, where should this code reside
or is there some configuration artifact that causes this instantiation 
to happen?





Why don't you take a look at these two articles:
http://today.java.net/pub/a/today/2005/11/15/using-jmx-to-manage-web-applications.html?page=1

http://marxsoftware.blogspot.com/2008/07/jmx-model-mbeans-with-apache-commons.html

If you use the NetBeans IDE you might be interested in the JMX plugin 
for NB. Here is a link to a tutorial Getting Started with JMX 
Monitoring in NetBeans IDE 6.0


http://www.netbeans.org/kb/60/java/jmx-getstart.html

cheers,
HH



Steve Cohen wrote:

H. Hall wrote:

Okay, thanks again.  This got me off square one.  Now on to square 
two.  :-)


1. I compose a legal mbeans-descriptor.xml file configuring my MBean 
according to DTD.  I place it in the domain Catalina.  Don't know 
if this is right.  Also tried my own domain name.
2. I launch Tomcat with parameters sufficient to launch JMX, define a 
port

etc.  This works.

3. I modify the simple Client.java from the Sun tutorial modifying 
the url to talk to my port and the jmxrmi context. This succeeds to 
the point of letting me iterate the list of available domain names.
4, When I use the version of the descriptor with a custom Domain 
name, this domain name does not even appear in the list and the 
Client app fails with a ClassNotFoundException.


5. When I use the version of the descriptor that places my mbean in 
the Catalina domain, my bean is not found within that Domain and the 
Client app also fails - with a ClassNotFoundException.


Is there a preexisting domain within Tomcat to which I should attach 
my mbean?  If not, what must I do to get my mbean found.




Steve Cohen wrote:
I am trying to write a custom MBean to put a particular function of 
our application under management control  This application is 
currently deployed under Tomcat 6.0.


I do not need remote monitoring/management.  Local management will 
do.  I am perfectly happy to invoke my management function through 
a shell script invoking a java jmx client to perform the action 
required.


I find the Tomcat documentation on this subject confusing and 
sparse.  The howto page here:

http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html

simply shows a sample configuration file without explaining which 
elements on it are required, which pertain to the specific example, 
etc.


Is there a standard syntax for these mbean descriptor files with a 
true explanation of each field?



I believe it's based on the Apache Commons Modeler.
Here is a link to the DTD for the Model MBeans Configuration File:
http://jakarta.apache.org/commons/dtds/mbeans-descriptors.dtd

Here is a link for the java doc for package 
org.apache.tomcat.util.modeler. Scroll down to description:
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/util/modeler/package-summary.html 



cheers,
HH


Also, compared to the standard Sun JMX tutorial - which elements 
does Tomcat provide - server, agent ?


Thanks.








-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






--
H. Hall
ReedyRiver Group LLC
http://www.reedyriver.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]



Re: Need help with Tomcat MBean support

2008-09-05 Thread Steve Cohen

Thanks again.  These articles are very clear and simple.

They do raise a couple questions, though. 

In the first article, no mention is made of an mbeans-descriptor.xml 
file.  It's all done programatically in the first article - which might 
be fine for my needs.  The Tomcat documentation does make it sound as 
though you can drop the xml file into your MBean package directory and 
something provided by Tomcat picks it up and makes the MBean accessible, 
but it now seems that this is not the case. 

The second article shows code to read these XML files (   
CommonsModelMBeanDemonstrator.applyCommonsModeler() ) which leads me to 
ask whether Tomcat comes with commons-modeler support built-in or 
whether this must be added manually as in this sample.


Anyway, it appears that there are two approaches here
1 - do everything programatically, in which case the .xml file isn't needed
2 - use the commons-modeler xml-file approach (question remains what 
support, if any, Tomcat provides for this). 


Do I have this right?



H. Hall wrote:

Steve Cohen wrote:

Let me ask my question a little more directly:

Does the presence of a descriptor cause instantiation of an instance 
of an MBean
or do I have to write code to create a server-side instance of my 
MBean and if so, where should this code reside
or is there some configuration artifact that causes this 
instantiation to happen?





Why don't you take a look at these two articles:
http://today.java.net/pub/a/today/2005/11/15/using-jmx-to-manage-web-applications.html?page=1 



http://marxsoftware.blogspot.com/2008/07/jmx-model-mbeans-with-apache-commons.html 



If you use the NetBeans IDE you might be interested in the JMX plugin 
for NB. Here is a link to a tutorial Getting Started with JMX 
Monitoring in NetBeans IDE 6.0


http://www.netbeans.org/kb/60/java/jmx-getstart.html

cheers,
HH





-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Tomcat MBean support

2008-09-04 Thread H. Hall

Steve Cohen wrote:
I am trying to write a custom MBean to put a particular function of 
our application under management control  This application is 
currently deployed under Tomcat 6.0.


I do not need remote monitoring/management.  Local management will 
do.  I am perfectly happy to invoke my management function through a 
shell script invoking a java jmx client to perform the action required.


I find the Tomcat documentation on this subject confusing and sparse.  
The howto page here:

http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html

simply shows a sample configuration file without explaining which 
elements on it are required, which pertain to the specific example, etc.


Is there a standard syntax for these mbean descriptor files with a 
true explanation of each field?



I believe it's based on the Apache Commons Modeler.
Here is a link to the DTD for the Model MBeans Configuration File:
http://jakarta.apache.org/commons/dtds/mbeans-descriptors.dtd

Here is a link for the java doc for package 
org.apache.tomcat.util.modeler. Scroll down to description:

http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/util/modeler/package-summary.html

cheers,
HH


Also, compared to the standard Sun JMX tutorial - which elements does 
Tomcat provide - server, agent ?


Thanks.





--
H. Hall
ReedyRiver Group LLC
http://www.reedyriver.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]



Re: Need help with Tomcat MBean support

2008-09-04 Thread Steve Cohen

Thank you very much - this is exactly what I was looking for.

And a word to the Tomcat team -

Documentation would be much improved by simply mentioning the two links 
provided by Mr. Hall.



H. Hall wrote:

Steve Cohen wrote:
I am trying to write a custom MBean to put a particular function of 
our application under management control  This application is 
currently deployed under Tomcat 6.0.


I do not need remote monitoring/management.  Local management will 
do.  I am perfectly happy to invoke my management function through a 
shell script invoking a java jmx client to perform the action required.


I find the Tomcat documentation on this subject confusing and 
sparse.  The howto page here:

http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html

simply shows a sample configuration file without explaining which 
elements on it are required, which pertain to the specific example, etc.


Is there a standard syntax for these mbean descriptor files with a 
true explanation of each field?



I believe it's based on the Apache Commons Modeler.
Here is a link to the DTD for the Model MBeans Configuration File:
http://jakarta.apache.org/commons/dtds/mbeans-descriptors.dtd

Here is a link for the java doc for package 
org.apache.tomcat.util.modeler. Scroll down to description:
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/util/modeler/package-summary.html 



cheers,
HH


Also, compared to the standard Sun JMX tutorial - which elements does 
Tomcat provide - server, agent ?


Thanks.








-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Tomcat MBean support

2008-09-04 Thread Mark Thomas
Steve Cohen wrote:
 Thank you very much - this is exactly what I was looking for.
 
 And a word to the Tomcat team -
 
 Documentation would be much improved by simply mentioning the two links
 provided by Mr. Hall.

Patches are always welcome.

Mark



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Tomcat MBean support

2008-09-04 Thread Steve Cohen

Soon as I get out of this time crunch I will try to do so.

Mark Thomas wrote:

Steve Cohen wrote:
  

Thank you very much - this is exactly what I was looking for.

And a word to the Tomcat team -

Documentation would be much improved by simply mentioning the two links
provided by Mr. Hall.



Patches are always welcome.

Mark



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



Re: Need help with Tomcat MBean support

2008-09-04 Thread Steve Cohen

H. Hall wrote:

Okay, thanks again.  This got me off square one.  Now on to square two.  :-)

1. I compose a legal mbeans-descriptor.xml file configuring my MBean 
according to DTD.  I place it in the domain Catalina.  Don't know if 
this is right.  Also tried my own domain name. 


2. I launch Tomcat with parameters sufficient to launch JMX, define a port
etc.  This works.

3. I modify the simple Client.java from the Sun tutorial modifying the 
url to talk to my port and the jmxrmi context. 
This succeeds to the point of letting me iterate the list of available 
domain names. 

4, When I use the version of the descriptor with a custom Domain name, 
this domain name does not even appear in the list and the Client app 
fails with a ClassNotFoundException.


5. When I use the version of the descriptor that places my mbean in the 
Catalina domain, my bean is not found within that Domain and the Client 
app also fails - with a ClassNotFoundException.


Is there a preexisting domain within Tomcat to which I should attach my 
mbean?  If not, what must I do to get my mbean found.




Steve Cohen wrote:
I am trying to write a custom MBean to put a particular function of 
our application under management control  This application is 
currently deployed under Tomcat 6.0.


I do not need remote monitoring/management.  Local management will 
do.  I am perfectly happy to invoke my management function through a 
shell script invoking a java jmx client to perform the action required.


I find the Tomcat documentation on this subject confusing and 
sparse.  The howto page here:

http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html

simply shows a sample configuration file without explaining which 
elements on it are required, which pertain to the specific example, etc.


Is there a standard syntax for these mbean descriptor files with a 
true explanation of each field?



I believe it's based on the Apache Commons Modeler.
Here is a link to the DTD for the Model MBeans Configuration File:
http://jakarta.apache.org/commons/dtds/mbeans-descriptors.dtd

Here is a link for the java doc for package 
org.apache.tomcat.util.modeler. Scroll down to description:
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/util/modeler/package-summary.html 



cheers,
HH


Also, compared to the standard Sun JMX tutorial - which elements does 
Tomcat provide - server, agent ?


Thanks.








-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Need help with Tomcat MBean support

2008-09-04 Thread Steve Cohen

Let me ask my question a little more directly:

Does the presence of a descriptor cause instantiation of an instance of 
an MBean
or do I have to write code to create a server-side instance of my MBean 
and if so, where should this code reside
or is there some configuration artifact that causes this instantiation 
to happen?



Steve Cohen wrote:

H. Hall wrote:

Okay, thanks again.  This got me off square one.  Now on to square 
two.  :-)


1. I compose a legal mbeans-descriptor.xml file configuring my MBean 
according to DTD.  I place it in the domain Catalina.  Don't know if 
this is right.  Also tried my own domain name.
2. I launch Tomcat with parameters sufficient to launch JMX, define a 
port

etc.  This works.

3. I modify the simple Client.java from the Sun tutorial modifying the 
url to talk to my port and the jmxrmi context. This succeeds to the 
point of letting me iterate the list of available domain names.
4, When I use the version of the descriptor with a custom Domain name, 
this domain name does not even appear in the list and the Client app 
fails with a ClassNotFoundException.


5. When I use the version of the descriptor that places my mbean in 
the Catalina domain, my bean is not found within that Domain and the 
Client app also fails - with a ClassNotFoundException.


Is there a preexisting domain within Tomcat to which I should attach 
my mbean?  If not, what must I do to get my mbean found.




Steve Cohen wrote:
I am trying to write a custom MBean to put a particular function of 
our application under management control  This application is 
currently deployed under Tomcat 6.0.


I do not need remote monitoring/management.  Local management will 
do.  I am perfectly happy to invoke my management function through a 
shell script invoking a java jmx client to perform the action required.


I find the Tomcat documentation on this subject confusing and 
sparse.  The howto page here:

http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html

simply shows a sample configuration file without explaining which 
elements on it are required, which pertain to the specific example, 
etc.


Is there a standard syntax for these mbean descriptor files with a 
true explanation of each field?



I believe it's based on the Apache Commons Modeler.
Here is a link to the DTD for the Model MBeans Configuration File:
http://jakarta.apache.org/commons/dtds/mbeans-descriptors.dtd

Here is a link for the java doc for package 
org.apache.tomcat.util.modeler. Scroll down to description:
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/util/modeler/package-summary.html 



cheers,
HH


Also, compared to the standard Sun JMX tutorial - which elements 
does Tomcat provide - server, agent ?


Thanks.








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