This discussion is archived
5 Replies Latest reply: Nov 6, 2010 6:23 AM by jtahlborn RSS

Static variable could not seem as attribute in JMX

713378 Newbie
Currently Being Moderated
Hi,

I defined a Global class and I have a static variable. I could not see them as attribute in jConsole. BTW, the methods could seem in jconsole. And, I used the class includes static variables as a Global class.

How can i see the static variable in jconsole?
  • 1. Re: Static variable could not seem as attribute in JMX
    JoachimSauer Journeyer
    Currently Being Moderated
    What is a "global class"?
    Why do you think all static variables would be accessible via JMX?
    What did you do to make the methods accessible via JMX in the first place?
  • 2. Re: Static variable could not seem as attribute in JMX
    713378 Newbie
    Currently Being Moderated
    Global class is a final Class it is not be instantiated.

    Static variables should be accessible because I want to monitor something ( for example file processing time or file sending time .. ). I set the variable as average time of file processing and I would like to monitor in jmx.

    In application-context xml in spring environment I represent the bean as mbean as below :
         <bean id="exporter3" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
         <property name="beans">
              <map><entry key="bean:name=Global" value-ref="Global"/></map>
         </property>
         </bean>
  • 3. Re: Static variable could not seem as attribute in JMX
    796440 Guru
    Currently Being Moderated
    crazy78 wrote:
    Global class is a final Class it is not be instantiated.
    "Global" has no meaning in Java. And final classes can be instantiated. It sounds like you're talking about a class full of static methods.
    Static variables should be accessible because I want to monitor something
    That answers why you want them to be accessible (and does a poor job of it at that). It does not answer the question he asked, which is why you think they are accessible.

    I want a million dollars. That doesn't mean I think I'll get it.
  • 4. Re: Static variable could not seem as attribute in JMX
    713378 Newbie
    Currently Being Moderated
    I could not understand both of you. I know there is no definition about "Global" class. I tried to tell a java class there is and its name is Global. It has only static variables ant static method that modifies and returns the static variables. I would like to monitor static variables values in jconsole. As I mentioned before, I could use the method in jConsole because "Operations" node seem in Bean Tree structure in MBeans tab in jConsole. But I could not see the "Attributes" node in jConsole on the class that I defined. My other bean's attributes could be seem in jConsole because all of them have been instantiated. Is there a way to monitor a class' variables in jconsole if the class has not been instantiated?
  • 5. Re: Static variable could not seem as attribute in JMX
    jtahlborn Expert
    Currently Being Moderated
    the jmx features in java operate solely on an instance of a class. all visible attributes/operations are based off of instance methods of the class. that said, i do not know what additional features the spring mbeanexporter may have.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points