Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7442663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:12:36+00:00 2026-05-29T11:12:36+00:00

Following various example configurations from Spring documentation as well as some forums on the

  • 0

Following various example configurations from Spring documentation as well as some forums on the Internet, my application context file looks like:

<beans>
    <bean id="dH" class="abc.def.ghi.DH">
        <constructor-arg>
            <value>0</value>
        </constructor-arg>
        <property name="num" value="100"/>
    </bean>
    <bean class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
            <property name="beans">
              <map>
                    <entry key="bean:name=dH1" value-ref="dH"/>
              </map>
            </property>
    </bean>
    <bean class="org.springframework.jmx.support.MBeanServerFactoryBean"/>
</beans>

I’m running this without any container and on plain JVM. I’m able to connect to my process via JConsole but the MBean doesn’t show up. However registering the bean programmatically exposes it successfully.

MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
DH dh = new DH(0);
mbeanServer.registerMBean(dh, new ObjectName("bean:name=dH1"));

I’ve tried playing with the Spring configuration without success. I think the bean is not registering to the already running MBean server that was accessible from ManagementFactory.getPlatformMBeanServer().
Any ideas on the issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:12:36+00:00Added an answer on May 29, 2026 at 11:12 am

    In addition to defining an MBeanServerFactory bean (as Nicholas noted in their answer) using …

    <bean class="org.springframework.jmx.support.MBeanServerFactoryBean">
        <property name="locateExistingServerIfPossible" value="true" />
    </bean>
    

    … you need to tell the MBeanExporter what to manage:

    If a bean implements one of the JMX management interfaces, MBeanExporter can simply register the MBean with the server through its autodetection process.

    If a bean does not implement one of the JMX management interfaces, MBeanExporter will create the management information using the supplied MBeanInfoAssembler.

    Assuming your abc.def.ghi.DH class does not implement any JMX interface, try defining your MBeanExporter as:

    <bean class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
        <property name="assembler">
            <bean
                class="org.springframework.jmx.export.assembler.MethodNameBasedMBeanInfoAssembler"
            >
                <property name="managedMethods">
                    <list>
                        <value>getNum</value>
                    </list>
                </property>
            </bean>
        </property>
        <property name="beans">
            <map>
                <entry key="bean:name=dH1" value-ref="dH"/>
            </map>
        </property>
    </bean>
    

    Looking at the OpenJDK 7, update 2, build 21 DefaultMBeanServerInterceptor.java source, line 898 creates a DynamicMBean for regular objects:

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);
    

    I haven’t debugged it, but I bet mbeanServer.registerMBean(dh, new ObjectName("bean:name=dH1")) eventually calls DefaultMBeanServerInterceptor.registerObject(), which creates a DynamicMBean for you and properly registers your standard JavaBean properties’ setters and getters.


    Here are some test files that work using Spring Framework 3.0.5 and Oracle HotSpot Java 1.6.0_24. After setting your CLASSPATH environment variable, just run javac *.java and java Main and use VisualVM (or similar application) to connect to the running java application to see the registered MBeans.

    ac.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans
        xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd"
        default-lazy-init="true"
    >
        <bean id="test" class="Test" />
        <bean class="org.springframework.jmx.support.MBeanServerFactoryBean">
            <property name="locateExistingServerIfPossible" value="true" />
        </bean>
        <bean class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
            <property name="assembler">
                <bean
                    class="org.springframework.jmx.export.assembler.MethodNameBasedMBeanInfoAssembler"
                >
                    <property name="managedMethods">
                        <list>
                            <value>getVal</value>
                            <value>setVal</value>
                        </list>
                    </property>
                </bean>
            </property>
            <property name="beans">
                <map>
                    <entry key="bean:name=Test" value-ref="test"/>
                </map>
            </property>
        </bean>
    </beans>
    

    Test.java:

    public class Test {
        private String val = "";
        public String getVal() {
            return val;
        }
        public void setVal(String v) {
            val = v;
        }
    }
    

    Main.java:

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    public class Main {
        public static void main(final String[] args) {
            ApplicationContext ac = new ClassPathXmlApplicationContext("ac.xml");
            try {
                Thread.sleep(1000 * 60 * 5);
            } catch (final Throwable t) {}
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following techniques from 'Modern C++ Design', I am implementing a persistence library with various
In the following example, GetFilteredCustomers() works fine so I can send various letters which
Take this following code from an example HR system. The user has the ability
I used to use the following to rename aplist file with various user inputted
What do the various pieces of uname -a output mean? Following is an example
I have various instances of strings that I need to split. Following are some
How can the following function be implemented in various languages? Calculate the (x,y) point
I have the following scenario: I have various user's data stored in my database.
I've been using the following code to create various struct, but only give people
Following on from my recent question on Large, Complex Objects as a Web Service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.