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 5948345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:05:39+00:00 2026-05-22T17:05:39+00:00

I’ve been trying to get a sample JMX MXBean working in a Spring-configured webapp,

  • 0

I’ve been trying to get a sample JMX MXBean working in a Spring-configured webapp, but any basic attributes on the MXBean are coming up as UNDEFINED when I connect with jconsole.

Java interface/classes:

public interface IJmxBean { // marker interface for spring config, see below
}

public interface MgmtMXBean { // lexical convention for MXBeans - mgmt interface
    public int getAttribute();
}

public class Mgmt implements IJmxBean, MgmtMXBean { // actual JMX bean
    private IServiceBean serviceBean;    // service bean injected by Spring
    private int attribute = 0;

    @Override
    public int getAttribute() {
        if(serviceBean != null) {
            attribute = serviceBean.getRequestedAttribute();
        }
        return attribute;
    }

    public void setServiceBean(IServiceBean serviceBean) { 
        this.serviceBean = serviceBean;
    }
}

Spring JMX config:

<beans>
    <context:component-scan base-package="...">
        <context:include-filter type="assignable" expression="...IJmxBean" />
    </context:component-scan>
    <context:mbean-export />
</beans>

Here’s what I know so far:

  • The element is correctly instantiating a bean named “mgmt”. I’ve got logging in a zero-argument public constructor that indicates it gets constructed.

  • is correctly automatically detecting and registering the MgmtMXBean interface with my Tomcat 6.0 container. I can connect to the MBeanServer in Tomcat with jconsole and drill down to the Mgmt MXBean.

  • When examining the MXBean, “Attribute” is always listed as UNDEFINED, but jconsole can tell the correct type of the attribute. Further, hitting “Refresh” in jconsole does not actually invoke the getter method of “Attribute”- I have logging in the getter method to indicate if it is being invoked (similar to the constructor logging that works) and I see nothing in the logs.

At this point I’m not sure what I’m doing wrong. I’ve tried a number of things, including constructing an explicit Spring MBeanExporter instance and registering the MXBean by hand, but it either results in the MBean/MXBean not getting registered with Tomcat’s MBean server or an Attribute value of UNDEFINED.

For various reasons, I’d prefer not to have to use Spring’s @ManagedResource/@ManagedAttribute annotations.

Is there something that I’m missing in the Spring docs or MBean/MXBean specs?

  • 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-22T17:05:40+00:00Added an answer on May 22, 2026 at 5:05 pm

    ISSUE RESOLVED: Thanks to prompting by Jon Stevens (above), I went back and re-examined my code and Spring configuration files:

    Throwing an exception in the getAttribute() method is a sure way to get “Unavailable” to show up as the attribute’s value in JConsole. In my case:

    • The Spring JMX config file I was using was lacking the default-autowire="" attribute on the root <beans> element;
    • The code presented above checks to see if serviceBean != null. Apparently I write better code on stackoverflow.com than in my test code, since my test code wasn’t checking for that. Nor did I have implements InitializingBean or @PostConstruct to check for serviceBean != null like I normally do on almost all the other beans I use;
    • The code invoking the service bean was before the logging, so I never saw any log messages about getter methods being entered;
    • JConsole doesn’t report when attribute methods throw exceptions;
    • The NPE did not show up in the Tomcat logs.

    Once I resolved the issue with serviceBean == null, everything worked perfectly. Regardless, +1 to Jon for providing a working demo, since there are literally 50 different ways to configure MBeans/MXBeans within Spring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.