Results 1 to 7 of 7

Thread: Full example of JMX in spring

  1. #1
    Join Date
    Aug 2004
    Posts
    15

    Default Full example of JMX in spring

    Hi,

    Can anyone tell me what else I need to do apart from the description from
    http://www.springframework.org/docs/reference/jmx.html, as I cannot see my bean in jconsole, although the program runs.

    It seems the code I added in XML file doesn't create the server at all.

    Do I need to code any for Mbean server part? if so can any one post a simple example for me, thanks.

  2. #2
    Join Date
    Aug 2004
    Posts
    15

    Default

    Sorry, I try to get a stand alone server with jdk 1.5.

  3. #3
    Join Date
    Aug 2004
    Posts
    15

    Default JConsole & MBeanServerFactoryBean

    So, why does the JConsole not show the Mbean when we use the MBeanServerFactoryBean to our configuration as shown in 18.2.1 of the JMX document. Java 1.5 VM has MBeanServer 1 : com.sun.jmx.mbeanserver.JmxMBeanServer server in there.
    Thanks.

  4. #4
    Join Date
    Aug 2004
    Posts
    15

    Default Instantiate objects!

    Spring configuration is only half part of the solution.
    You have also to instantiate the objects defined into the configuration.

    Example:

    Code:
    <beans>
            <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/>
    
            <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
                    <property name="beans">
                            <map>
                                    <entry key="bean&#58;name=test" value-ref="testBean"/>
                            <map>
                    </property>
    
                    <property name="server" ref="mbeanServer"/>
            </bean>
    
            <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean">
                    <property name="objectName" value="connector&#58;name=rmi"/>
                    <property name="serviceUrl"
                              value="service&#58;jmx&#58;rmi&#58;//localhost/jndi/rmi&#58;//localhost&#58;1099/myconnector"/>
    
                    <property name="threaded" value="true"/>
                    <property name="daemon" value="true"/>
                    <property name="server">
                            <ref local="mbeanServer"/>
                    </property>
            </bean>
    
            <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
              <property name="port" value="1099"/>
            </bean>
    
    ...
    In your application:

    Code:
    public static void main&#40;String&#91;&#93; args&#41; &#123;
    
      ...
     Object serverConnector=getFactory&#40;&#41;.getBean&#40;"serverConnector"&#41;;
     Object exporter=getFactory&#40;&#41;.getBean&#40;"exporter"&#41;;
     ...
    &#125;
    That's All!

    (As in test\org\springframework\jmx\export\MBeanExporterT ests.java)

  5. #5
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    You have a working example inside the spring distribution.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  6. #6
    Join Date
    Sep 2011
    Posts
    3

    Default The same problem

    I have the same problem, I can't see my bean in jconsole. I read the previous post, but I do not understand the lines of code to initialize the objects defined in the configuration because they have many strange characters, plus I do not know where are the examples in the distribution of spring. I'm very new in spring someone can help me please?

    Thanks in advance

  7. #7
    Join Date
    Jan 2012
    Posts
    6

    Default

    public class AnnotatedStandardMBean extends StandardMBean {

    /** Instance where the MBean interface is implemented by another object. */
    public <T> AnnotatedStandardMBean(T impl, Class<T> mbeanInterface)
    throws NotCompliantMBeanException {
    super(impl, mbeanInterface);
    }

    /** Instance where the MBean interface is implemented by this object. */
    protected AnnotatedStandardMBean(Class<?> mbeanInterface)
    throws NotCompliantMBeanException {
    super(mbeanInterface);
    }

    @Override
    protected String getDescription(MBeanOperationInfo op) {
    ...
    }

    ...other overrides...
    }



    Business School Rankings
    Best MBA Programs

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Replies: 5
    Last Post: Aug 9th, 2008, 05:30 AM
  3. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 1
    Last Post: Nov 10th, 2004, 03:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •