Solved

Creating an MBeanServer?

Posted on 2010-11-24
6
282 Views
Last Modified: 2012-05-10
I have a standard application and I want to expose an MBean. Currently I am doing the following in my application init:


final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
                  ObjectName name;

                  name = new ObjectName("com.example:type=myMBean");

                  final myMBean mbean = new myMBean();
                  mbs.registerMBean(mbean, name);

This was taken from the link, and I assume if I've done it right I can directly access the MBean via JConsole.

I was also looking at the Spring Implementation, but am unsure if I am required to start a server first:

http://static.springsource.org/spring/docs/2.5.x/reference/jmx.html


Essentially all I want to do is have my standalone application make the MBean availble so that JConsole can be used to extract the required information.

Cheers
0
Comment
Question by:directxBOB
  • 2
  • 2
  • 2
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 34203321
> final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

this should create a server
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 250 total points
ID: 34203374
make sure you pass the necessary command line args,

-Dcom.sun.management.jmxremote.port=60000
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
0
 

Author Comment

by:directxBOB
ID: 34257767
Having problems with this at the moment, still trying to debug through exactly what is going wrong.


final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
                  ObjectName name;

                  name = new ObjectName("com.example:type=myMBean");

                  final myMBean mbean = new myMBean();
                  mbs.registerMBean(mbean, name);




Should myMbean be the actual Interface or Implementation class?


The exception I am getting out is:

Additional Info      MBean, Non Compliant MBean : MBean class myMBean does not implement DynamicMBean, neither follows the Standard MBean conventions (javax.management.NotCompliantMBeanException: Class myMBean is not a JMX compliant Standard MBean) nor the MXBean conventions (javax.management.NotCompliantMBeanException: myMBean: Class myMBean is not a JMX compliant MXBean)


Any ideas?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 34262415
sounds like theres a problem with your myMBean class
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 250 total points
ID: 34264852
you should register it as a type of StandardMBean!
0
 

Author Closing Comment

by:directxBOB
ID: 34588489
Sorry about delay with this, been swamped with work, and not got around to wrapping up the MBean
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now