Re: looking for sample MBean code for tomcat 6
Please read this: http://java.sun.com/developer/technicalArticles/J2SE/jmx.html http://java.sun.com/j2se/1.5.0/docs/guide/jmx/tutorial/tutorialTOC.html Peter Am 09.01.2008 um 08:03 schrieb Frank Z: hello, I am looking some sample MBean code for TC 6.0.. I was able to model some code after the source code (e.g. MemoryUserDatabaseMBean.java in the org.apache.catalina.users. package) . I was also able to create the mbeans-descriptor.xml One question that I have is that even though the code compiled and deployed TC, i am not able to see my custom MBean via JConsole . Are there additional things needed to get the MBean registered properly in TC? Thanks in advance. __ __ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/ newsearch/category.php?category=shopping - 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: looking for sample MBean code for tomcat 6
Hi Peter, Thanks for sending the link. I guess what my real question was: how would I get TC to 'declaratively' instantiate my MBeans ? From the example, most of them has a main() method to instantiate and register the MBeans to the platform MBean Server. What would you recommend for TC , a servlet that loads on startup and within the init method it would create and register the MBeans? I am porting my MBeans from JBoss (embedding TC) and JBoss provides a declarative method do so without the needs of a servlet. It is done by creating a service archive (e.g. myservice.sar - containing a jboss-service.xml [similar to mbeans-descriptor.xml] that declares the MBeans). The JBoss container would then instantiate the MBeans via the MBean's start() method. public class Main { public static void main(String[] args) throws Exception { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName(com.example.mbeans:type=Hello); Hello mbean = new Hello(); mbs.registerMBean(mbean, name); System.out.println(Waiting forever...); Thread.sleep(Long.MAX_VALUE); } } Thanks Frank. - Original Message From: Peter Rossbach [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Wednesday, January 9, 2008 1:20:10 AM Subject: Re: looking for sample MBean code for tomcat 6 Please read this: http://java.sun.com/developer/technicalArticles/J2SE/jmx.html http://java.sun.com/j2se/1.5.0/docs/guide/jmx/tutorial/tutorialTOC.html Peter Am 09.01.2008 um 08:03 schrieb Frank Z: hello, I am looking some sample MBean code for TC 6.0.. I was able to model some code after the source code (e.g. MemoryUserDatabaseMBean.java in the org.apache.catalina.users. package) . I was also able to create the mbeans-descriptor.xml One question that I have is that even though the code compiled and deployed TC, i am not able to see my custom MBean via JConsole . Are there additional things needed to get the MBean registered properly in TC? Thanks in advance. __ __ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/ newsearch/category.php?category=shopping - 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] Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs - 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: looking for sample MBean code for tomcat 6
--- HARBOR: http://coolharbor.100free.com/index.htm The best application server on earth --- Hi Frank, I played with this a long time ago, and I've completely forgotten what I did. When it comes to monitoring servlets (own code) I came to the conclusion that its very hard to top a web server and an admin web page behind a password... but ok thats why I didnt persue it. But there were 2 links in particular that I found very useful... http://oss.wxnet.org/mbeans.html which talks about general tomcat config your question is in there, the Mbean starts with a context listener. and this... http://www.netbeans.org/kb/articles/jmx-tutorial.html which is a JMX plug-in for NB... makes testing and just getting the formats right easy. and then on tomcat I vaguely remember having to set up DJava command lines so the TC would expose a port to Jconsole... I dont remember seeing XML config to explicitly start a Mbean, I remember seeing that EJB containers tend to automate all this for you but servlet containers tend to be a little more manual. Anyway I think armed with those tools, you'll be on your way. I rember seeing it work on TC 5.5 but I dont think much changes other than the location of common/lib Have fun hello, I am looking some sample MBean code for TC 6.0.. I was able to model some code after the source code (e.g. MemoryUserDatabaseMBean.java in the org.apache.catalina.users. package) . I was also able to create the mbeans-descriptor.xml One question that I have is that even though the code compiled and deployed TC, i am not able to see my custom MBean via JConsole . Are there additional things needed to get the MBean registered properly in TC? Thanks in advance. Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping - 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: looking for sample MBean code for tomcat 6
Hi Frank, you can add your Mbeans at following file === $catalina.base/conf/tomca5-mbeans.xml == bean mbean name=Bean:type=Bean code=test.MyBean attribute name=name value=Peter/ /mbean jmx-operation objectName=Bean:type=Bean operation=show/ mbean name=Bean:type=Bean2 code=test.MyBean/ jmx-operation objectName=Bean:type=Bean2 operation=setAll arg type=java.lang.String value=Willy/ arg type=java.lang.StringGo to water/arg /jmx-operation jmx-operation objectName=Bean:type=Bean2 operation=show/ /bean === The Engine element at server.xml can load those MBean instance declaration. Server ... ... Engine name=Catalina mbeansFile=${catalina.base}/conf/tomcat5-mbeans.xml defaultHost=localhost jvmRoute=node01 ... If you implement a init(),start()/stop(),destroy() method your MBeans also notified from Engine Lifecycle :-) Install your MBean Code at common or server classLoader. === common/classes/test/MyBean.java package test; public class MyBean implements MyBeanMBean { private String name ; public String getName() { return name ; } public void setName(String name) { this.name = name ; System.out.println(name) ;} private String street ; public String getStreet() { return street ; } public void setStreet(String street) { this.street = street ; System.out.println(street) ; } public void show() { System.out.println(name + -- + street) ; } public void setAll(String name , String street) { this.name = name ; this.street = street ; } } === === common/classes/test/MyBeanMBean.java package test; public interface MyBeanMBean { public String getName() ; public void setName(String name) ; public String getStreet() ; public void setStreet(String street) ; public void show() ; public void setAll(String name , String street); } I test the example with tomcat 5.5.25. I am hasn't tested with tomcat 6, but the insourced modeler code seems also working! Regards Peter Look at my old fixed issue : http://issues.apache.org/jira/browse/ MODELER-17 But I am not sure that that patch at 2.0.1 is complete ( jmx- attribute element not exists) Am 09.01.2008 um 17:25 schrieb Frank Z: Hi Peter, Thanks for sending the link. I guess what my real question was: how would I get TC to 'declaratively' instantiate my MBeans ? From the example, most of them has a main() method to instantiate and register the MBeans to the platform MBean Server. What would you recommend for TC , a servlet that loads on startup and within the init method it would create and register the MBeans? I am porting my MBeans from JBoss (embedding TC) and JBoss provides a declarative method do so without the needs of a servlet. It is done by creating a service archive (e.g. myservice.sar - containing a jboss-service.xml [similar to mbeans-descriptor.xml] that declares the MBeans). The JBoss container would then instantiate the MBeans via the MBean's start() method. public class Main { public static void main(String[] args) throws Exception { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName (com.example.mbeans:type=Hello); Hello mbean = new Hello(); mbs.registerMBean(mbean, name); System.out.println(Waiting forever...); Thread.sleep(Long.MAX_VALUE); } } Thanks Frank. - Original Message From: Peter Rossbach [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Wednesday, January 9, 2008 1:20:10 AM Subject: Re: looking for sample MBean code for tomcat 6 Please read this: http://java.sun.com/developer/technicalArticles/J2SE/jmx.html http://java.sun.com/j2se/1.5.0/docs/guide/jmx/tutorial/ tutorialTOC.html Peter Am 09.01.2008 um 08:03 schrieb Frank Z: hello, I am looking some sample MBean code for TC 6.0.. I was able to model some code after the source code (e.g. MemoryUserDatabaseMBean.java in the org.apache.catalina.users. package) . I was also able to create the mbeans-descriptor.xml One question that I have is that even though the code compiled and deployed TC, i am not able to see my custom MBean via JConsole . Are there additional things needed to get the MBean registered properly in TC? Thanks in advance. _ _ __ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/ newsearch/category.php?category=shopping - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
looking for sample MBean code for tomcat 6
hello, I am looking some sample MBean code for TC 6.0.. I was able to model some code after the source code (e.g. MemoryUserDatabaseMBean.java in the org.apache.catalina.users. package) . I was also able to create the mbeans-descriptor.xml One question that I have is that even though the code compiled and deployed TC, i am not able to see my custom MBean via JConsole . Are there additional things needed to get the MBean registered properly in TC? Thanks in advance. Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]