Using JMX and MBeans

I've been experimenting with Java instrumentation with MBeans.
I created a small app to try out some of the JMX features. The app has a class that I would like to monitor with MBeans. So I created to interfaces to function as MBeans and then had the class in my app implement both interfaces.
I then wrote a class with only a main() method to instantiate my class and call the methods it implemented from my MBean interface. In the main method I provided the code to get an MBeanServer object and then use that to register my class that implemented the MBean interfaces. My intention was to try this out, but before I did I commented out the code needed to register the class with the MBean server. I did this because I assumed the implemented interface methods would be available for monitoring without registering and it made me think if I can monitor the instrumented class like this why would I need the MBean server.
So what is the purpose of the JMX framework and MBeans if I can instrument any class as described above?
Is it necessary to register only to be able to monitor from outside the JMV where the instrumented class is running?
Or are there other advantages\features\reasons for registering with the MBean server?
Thanks

"MS" <[email protected]> wrote:
>
Hello All,
I am looking for a java program that can create JDBC connection pool
and datasource
using JMX/Mbeans of WLS 7.0.2.
Can somebody help?
Thanks in advance.
rgds
MS

Similar Messages

  • Monitoring of server using JMX and SNMP

    hi
    I want to monitor my server using SNMP to get the information about craches, response time etc of the server. What technology should I use to do the same? Can JMX help me for this and How?
    Thanks in advance
    kiran

    Hello Frederic,
    your request is a system monitoring request and not really a BPMon request. As BPMon is designed to monitor specific steps of a business process it doesn't make sense to use a wildcard for the object. A certain business process step like "Create Sales Orders" is only executed via certain transaction like VA01. So it would n't make sense to monitor also MM or PP transactions for the same process step. For this reason wildcards are not allowed.
    For your system monitoring problem you either use the normal CCMS monitor for Update Errors which counts all update errors in one system (and you can include the CCMS MTE in BPMon via the CCMS monitoring object) or you decide to use the BPMon Update error monitor for selected important transactions only.
    Anyhow you should first do a systematic error analysis with transaction SM13 why you encounter so many update errors at all and solve the root cause. 1000 Update errors is a very high/bad value even if you had a large system.
    Best Regards
    Volker

  • How to use JMX

    Hi, all,
    I am newbie in JMX. I want to know what software,such as API and so on, i must need to use JMX .and I want some tutorials of JMX.
    thanks.
    Kaven

    Check out the JMX listserv archives at
    http://archives.java.sun.com
    and look for JMX-FORUM.
    Theres information in there, and coincidentally over that last two days people have been asking the exact same question - look for the replies to topic "help ... get me started" - lots of links there.
    There is also the sun JMX home page.
    There are a few commercial implementations of JMX and at least 2 open source ones - search the JMX-FORUM for "open" if you're interested in that. Plus Sun supplies a reference implementation ( although I haven't used that.)
    Personally I use JDMK, Sun's implementation, and I've found it meets my needs ( but then I'm not paying for the licence, my company is.) and it is available as an evaluation copy before you buy. It comes with tutorials, but I wouldn't be surprised if the others do as well.
    Try and search the sun site and google for JMX, there'll be stuff there.
    Finally, go to Amazon.com and look for "java and jmx" - there is at least one book out there.

  • How to add target to jmsSystemResource MBean using JMX

    Does anybody know how to add target to jmsSystemResource MBean using JMX in WebLogic 9.0?(I am not using WSLT) I always get "NoSuchMethodException":
              [jmsServer] Caused by: java.lang.NoSuchMethodException: addTarget(weblogic.management.configuration.
              TargetMBean,) for com.bea:Name=admin01DefaultJMSServer,Type=JMSSystemResource

    go to the object which u want to compare
    go to->version management->select the TR request no->and select remote comparision there->and give the system where u need to compare this object
    and next press compare
    hope it will work
    cheer
    s.janagar

  • Basic MIB and SNMP understanding using JMX

    Hello
    i am trying to get my head around SNMP using JMX, but i am finding it dificult to know where to start.
    ideally i would love to find some basic code and go through it, so that i can understand it.
    i would love to find some code which just "Gets" one parameter from a mib stored on a seperate PC and displays it on another PC.
    I have looked at advent - to complex for what i want.
    Any help or suggestions - or possibly Code!! would be appreciated.
    Thanks
    Norman

    There is an example code included in the upcoming book "JMX: Managing J2EE with Java Management Extensions" that shows how to retrieve a simple attribute value from an JMX SNMP Adaptor using the Sun JDMK and AdventNet SNMP toolkits. It's a brief introduction to SNMP integration but should get you started.
    http://www.amazon.com/exec/obidos/ASIN/0672322889/104-6670791-7933546
    Unfortunately you still have to wait a week or two to get it.
    Basically the examples show how you can generate the required MBeans from an SNMP MIB definition (in Sun's JDMK this is a tool called MibGen), then register the SNMP Adaptor to the MBean server and associate and register the MBeans that were generated from the MIB to the adaptor. You can then use an SNMP client to connect to the adaptor and manipulate the MBeans through SNMP.
    Hope this is of some help.
    -- Juha

  • JMX Remote and MBeans in separate Processes

    Hi,
    I found on Sun blogs - http://blogs.sun.com/jmxetc/entry/what_is_jmx
    following:
    "An EJB lives in an Application Server container. It usually implements business logic. An MBean lives in an MBeanServer, and usually implements management logic"
    That means, when an MBeanServer is killed, an MBeans dont't run anymore?
    I have several Java applications.
    I want use the JMX to manage (remote) this applications (start, stop, status watch) I created one MBean for every application and registered them on an MBeanServer. I can now start, stop application and observe the status.
    public interface AdapterMBean {
    String getStatus();
    void start();
    void stop();
    But when I kill the process of MBeanServer, my applications don't run anymore.
    Method start() starts application in new Thread.
    Can JMX fulfil this requirement, that an MBeanServer runs in its own process and MBeans run in separate processes (now on the same machine)?
    If yes, what shoul I do?
    thanx
    Peter

    Hi,
    I found on Sun blogs -
    http://blogs.sun.com/jmxetc/entry/what_is_jmx
    following:
    "An EJB lives in an Application Server container. It
    usually implements business logic. An MBean lives in
    an MBeanServer, and usually implements management
    logic"
    That means, when an MBeanServer is killed, an MBeans
    dont't run anymore?You don't kill an MBeanServer. What do you mean by 'kill an MBeanServer'?
    I have several Java applications.
    I want use the JMX to manage (remote) this
    applications (start, stop, status watch) I created
    one MBean for every application and registered them
    on an MBeanServer. I can now start, stop application
    and observe the status.
    public interface AdapterMBean {
    String getStatus();
    void start();
    void stop();
    But when I kill the process of MBeanServer, my
    applications don't run anymore.
    Method start() starts application in new Thread.
    Can JMX fulfil this requirement, that an MBeanServer
    runs in its own process and MBeans run in separate
    processes (now on the same machine)?
    If yes, what shoul I do?
    thanx
    PeterWhen you kill a process, you kill all its execution threads.
    A thread is not a process. It runs within a process.
    If you want your applications to remain alive when you kill
    the process that started them you need to start them in a
    new separate process. See System.exec().
    The question is: why do you kill the process that runs all your
    applications in the first place?
    Are you sure you are doing what you want to do?
    regards,
    -- daniel
    JMX, SNMP, Java, etc...
    http://blogs.sun.com/roller/page/jmxetc

  • How to monitor an application using JMX

    Hi,
    How can I monitor the portal application running on  portal server by using MBeans (JMX)? For this I need to make a connection between my portal application and  MBean class, How to monitor operations? How can I do that? If anybody has come across the same requirement pls explain me with the implementation details.

    Hello,
    I have done that in a project (not Portal, but pure Java Application, should be no difference), working fine.
    The steps are as follows:
    - create MBean Server (e.g. MBeanServerFactory.createMBeanServer("test");)
    - create your MBeans
    - make them accessible to clients (register the MBeans in the server)
    - query them from clients
    see http://java.sun.com/developer/technicalArticles/J2SE/jmx.html
    for very good explanation including sample source code.
    CSY

  • Using JMX to get status information about NetWeaver cluster

    Hi everybody,
    We are trying to use JMX to get some status information about NetWeaver cluster.
    For example, using the MBean with the name u201Ccom.sap.default:name=EL1,j2eeType=SAP_J2EEClusteru201D we can obtain the list of all instances running in cluster. Here an instance is a u201CJava instanceu201D in the NetWeaver terminology.
    The method u201CgetInstanceNodeIDsu201D provides us with a list of all nodes of an instance.
    Concretely, calling this method for a cluster running on one machine with two java processes, we get the following list of node Ids: u201C0, 1476420, 1476450, 1476451u201D where the last two correspond to the two java processes.
    What are the first two node Ids from the list?
    How can the last two node Ids be identified as java processes?
    How can we obtain status information about each java process (node id) ?
    Thanks for all ideas,
    Radu

    As there seems to be a lot of interest in this subject, and since I found some form of solution, I thought I'd share it with you.
    In the es-cli interface, there is a thing called browse mode. Activate it by typing browse after logging in.
    Now you can easily browse your network and all of the managed objects. Use getattributes at the end of each branch to see the properties of objects. So far, I've indexed all of the kernel reader module, the health monitor module, the common config reader and the config reader for workgroup servers. If my employer allows, I will post results to http://tille.garrels.be/training/sunmc/ - check later this week.
    Machtelt.

  • How to get application's state on weblogic server using jmx.

    I want to get application state using JMX, I am able to get application list, name but not able to find its state. Some code snippet mentioned below. Please let me know if I can use some other MBean
    Thanks in advance..
    static {
    try {
    service = new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean");
    }catch (MalformedObjectNameException e) {
    throw new AssertionError(e.getMessage());
    * Initialize connection to the Domain Runtime MBean Server
    public static void initConnection(String hostname, String portString, String username, String password) throws IOException, MalformedURLException
    String protocol = "t3";
    int port = Integer.parseInt(portString);
    String jndiroot = "/jndi/";
    String mserver = "weblogic.management.mbeanservers.domainruntime";
    JMXServiceURL serviceURL= new JMXServiceURL(protocol,hostname, port, jndiroot+mserver);
    // JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, portString, jndiroot , mserver);
    Hashtable h = new Hashtable();
    h.put(Context.SECURITY_PRINCIPAL, username);
    h.put(Context.SECURITY_CREDENTIALS, password);
    h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,
    "weblogic.management.remote");
    connector = JMXConnectorFactory.connect(serviceURL, h);
    connection = connector.getMBeanServerConnection();
    * Get an array of ServerRuntimeMBeans
    public static ObjectName[] getServerRuntimes() throws Exception {
    return (ObjectName[]) connection.getAttribute(service,
    "ServerRuntimes");
    * Get an array of WebAppComponentRuntimeMBeans
    public void getApplicationData() throws Exception {
    ObjectName[] serverRT = getServerRuntimes();
    int length = (int) serverRT.length;
    for (int i = 0; i < length; i++) {
    ObjectName[] appRT =
    (ObjectName[]) connection.getAttribute(serverRT,
    "ApplicationRuntimes");
    int appLength = (int) appRT.length;
    for (int x = 0; x < appLength; x++) {
    System.out.println("Application name: " +
    (String)connection.getAttribute(appRT[x], "Name")+"Application Status"+(String)connection.getAttribute(appRT[x], "State"));
    public static void main(String[] args) throws Exception {
    String hostname = "*****.us.oracle.com";
    String portString = "*****";
    String username = "***";
    String password = "****";
    JMXUtil s = new JMXUtil();
    initConnection(hostname, portString, username, password);
    s.getApplicationData();
    connector.close();

    register at elicense.bea.com and ask there.
    but, a license is a license, as long as the ipaddr is not restricted.
    Wayne
    Bora wrote:
    I downloaded an Evaluation copy from BEA but it expires in 30 days. The place I
    work has licenses for HPUX but I need to have a copy on my laptop for development
    & test.
    Thanks for help!
    Sincerely
    Bora

  • Weblogic.security.service.NotYetInitializedException using JMX

    Hi there,
    I'm trying to use JMX to add a notification listener to listen for attribute changes to a WLS 8.1 MBean. My code when setting up the listener is as so:
    String url = "t3://localhost:7001";
    String serverName = "Server1";
    String userName = "weblogic";
    String password = "weblogic";
    MBeanHome home = null;
    RemoteMBeanServer rmbs = null;
    Environment env = new Environment();
    env.setProviderUrl(url);
    env.setSecurityPrincipal(userName);
    env.setSecurityCredentials(password);
    try {
         Context ctx = env.getInitialContext();
         home = (MBeanHome) ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
    } catch (NamingException e) {
         e.printStackTrace();
    rmbs = home.getMBeanServer();
    WLListener listener = new WLListener();
    WebLogicObjectName mbeanName = new WebLogicObjectName("examplesServer", "Server", "examples");
    rmbs.addNotificationListener(mbeanName, listener, null, null);This seems to work fine, I do not get any error messages. As you can see I'm using the server started through the examples, and I'm adding a notification listener to the ServerMBean.
    My notification listener code is as so:
    public void handleNotification(Notification notification, Object arg1) {
         AttributeChangeNotification changedAttrib = (AttributeChangeNotification) notification;
         try {
              System.out.println("Changed value from: " + changedAttrib.getOldValue() + " to " + changedAttrib.getNewValue());
         } catch (Exception ex) {
              ex.printStackTrace();
    public boolean isNotificationEnabled(Notification arg0) {
         return true;
    }Only when a notification happens and I call getOldValue() I get:
    weblogic.security.service.NotYetInitializedException: [Security:090392]SecurityServiceManager not yet initialized.
         at weblogic.security.service.SecurityServiceManagerDelegateImpl.getSecurityService(SecurityServiceManagerDelegateImpl.java:156)
         at weblogic.security.service.SecurityServiceManager.getSecurityService(SecurityServiceManager.java:175)
         at weblogic.management.internal.SecurityHelper.getRoleManager(SecurityHelper.java:402)
         at weblogic.management.internal.SecurityHelper.access$100(SecurityHelper.java:54)
         at weblogic.management.internal.SecurityHelper$IsAccessAllowedPrivilegeAction.run(SecurityHelper.java:493)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
         at weblogic.management.internal.SecurityHelper.isAccessAllowed(SecurityHelper.java:393)
         at weblogic.management.internal.AttributeChangeNotification.getOldValue(AttributeChangeNotification.java:136)
         at com.xxxx.password.PasswordBme$WLListener.handleNotification(PasswordBme.java:76)
         at com.xxxx.password.PasswordBme$WLListener_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)Is there a step I'm missing out? The entry for this message in the documentation suggests calling BEA support.

    Hi there,
    I'm trying to use JMX to add a notification listener to listen for attribute changes to a WLS 8.1 MBean. My code when setting up the listener is as so:
    String url = "t3://localhost:7001";
    String serverName = "Server1";
    String userName = "weblogic";
    String password = "weblogic";
    MBeanHome home = null;
    RemoteMBeanServer rmbs = null;
    Environment env = new Environment();
    env.setProviderUrl(url);
    env.setSecurityPrincipal(userName);
    env.setSecurityCredentials(password);
    try {
         Context ctx = env.getInitialContext();
         home = (MBeanHome) ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
    } catch (NamingException e) {
         e.printStackTrace();
    rmbs = home.getMBeanServer();
    WLListener listener = new WLListener();
    WebLogicObjectName mbeanName = new WebLogicObjectName("examplesServer", "Server", "examples");
    rmbs.addNotificationListener(mbeanName, listener, null, null);This seems to work fine, I do not get any error messages. As you can see I'm using the server started through the examples, and I'm adding a notification listener to the ServerMBean.
    My notification listener code is as so:
    public void handleNotification(Notification notification, Object arg1) {
         AttributeChangeNotification changedAttrib = (AttributeChangeNotification) notification;
         try {
              System.out.println("Changed value from: " + changedAttrib.getOldValue() + " to " + changedAttrib.getNewValue());
         } catch (Exception ex) {
              ex.printStackTrace();
    public boolean isNotificationEnabled(Notification arg0) {
         return true;
    }Only when a notification happens and I call getOldValue() I get:
    weblogic.security.service.NotYetInitializedException: [Security:090392]SecurityServiceManager not yet initialized.
         at weblogic.security.service.SecurityServiceManagerDelegateImpl.getSecurityService(SecurityServiceManagerDelegateImpl.java:156)
         at weblogic.security.service.SecurityServiceManager.getSecurityService(SecurityServiceManager.java:175)
         at weblogic.management.internal.SecurityHelper.getRoleManager(SecurityHelper.java:402)
         at weblogic.management.internal.SecurityHelper.access$100(SecurityHelper.java:54)
         at weblogic.management.internal.SecurityHelper$IsAccessAllowedPrivilegeAction.run(SecurityHelper.java:493)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
         at weblogic.management.internal.SecurityHelper.isAccessAllowed(SecurityHelper.java:393)
         at weblogic.management.internal.AttributeChangeNotification.getOldValue(AttributeChangeNotification.java:136)
         at com.xxxx.password.PasswordBme$WLListener.handleNotification(PasswordBme.java:76)
         at com.xxxx.password.PasswordBme$WLListener_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)Is there a step I'm missing out? The entry for this message in the documentation suggests calling BEA support.

  • Enterprise monitoring using JMX

    Hello,
    So, my company has a lot of J2EE/Tomcat servers running on java 1.6. I'm trying to find a way to monitor them all via JMX from a centralized system, which would be accessible to multiple users (web based, ideally).
    Based on my understanding of JMX, it should be possible to extract the data we need from each JVM. I have been using JConsole to do this on an ad-hoc basis when we have problems with a particular JVM and it's great.
    But I can't seem to find any good software for doing enterprise-wide monitoring and long-term data collection... can anyone suggest a good package, either free/open-source (ideally) or commercial?
    Basically, I want to be able to:
    * collect CPU, memory, DB (hibernate), HTTP request stats, etc. via JMX and archive it
    * view graphs of the above
    * ideally, we could also receive email alerts if certain conditions were met, e.g. memory almost full.
    As a side note:
    We're already using Zenoss (http://www.zenoss.com) to monitor the OS-level stuff and we really like it, but we need more visibility into each JVM (we have multiple JVMs per physical server). As far as I can tell, Zenoss doesn't support JMX monitoring... but has anyone found a way to make this work? If so, I'd love to hear about it, since this would be ideal for me.

    You may want to have a look at Glassbox, an open source troubleshooting agent for pinpointing problems in Enterprise Java applications.
    http://www.glassbox.com
    It offers both JMX and web-based access to the collected data but I'm not sure the web-based console allows you to present the collected data graphically. But still you could write your own JConsole plugins and display the collected
    data coming from Glassbox and your own custom MBeans in a graphical way but of course JConsole is Swing-based.
    Have a look at the JavaOne 2007 Hands-On Lab 1420 to get more detailed info about using Glassbox/JMX/JConsole together.
    http://blogs.sun.com/lmalventosa/entry/j1_07_hol_1420
    Regards,
    Luis-Miguel Alventosa
    Java SE JMX/JConsole development team
    Sun Microsystems, Inc.
    http://blogs.sun.com/lmalventosa/

  • JMX and Webservice

    Hi,
    I am using JMX in my application which supports HTTP, RMI, CORBA, TL1 and SNMP protocols. Now I am planning to include SOAP as well. Looking at this scenario, I have the following questions:
    1. Do I really need to support SOAP in JMX? The logic here is SOAP is already platform independent, so why not directly use webservices.
    2. Which version of Axis can be used with any SOAP implementation in JMX (Axis/Axis2)?
    3. Is there any commercially free connector available? If yes, how is the performance of this connector?
    4. What will be the deployment scenario (since there is not much documentation available)?
    Any inputs will be valuable.
    -Sandeep

    sandeep_khurana wrote:
    georgemc wrote:
    sandeep_khurana wrote:
    Yes. I have used JMX in my application.To do what?In my application, JMX is used for exposing some details like version, health, etc. and this information can be accessed by the above mentioned protocols.
    Now I need to have SOAP integration as well. So, there are doubts introduced?
    Can you please help?So you've got some MBeans, and you want to expose them over as many different protocols as possible? No reason why you can't do that, if that's what you really want. Sounds like overkill, or a refusal to consider actual requirements, to be honest. The fact that JMX is at one end of the equation is pretty much irrelevant, it's all going to just be data as far as SOAP's concerned.

  • Using JMX to database monitoring

    Hello, I'm a software developer, and I want to use JMX to database monitoring.
    I did sth to see in jconsole some data from our database, but Ive got problem to
    refresh it. I mean when jconsole is running and somebody makes changes in DB
    how can I see it on monitor ... ?? Something like dynamic MBeans ??
    second question - is it possible to use MXBean in java 1.5 ??
    thanks for answers
    PS. we are using Java 5 unfortunetelly

    oh I should say that:
    -I'm using jconsole to monitoring jobs i DB;
    -every job has its own MBean;
    -of course if some changes in already defined jobs occure - its no problem;
    Problem is when somebody create/delete jobs ... how can I using refresh button on jconsole get information about new job ?

  • Weblogic database resources using JMX

    Does anyone have an idea on how to get user defined Datasource information from Weblogic server using JMX?
    I have tried with different ObjectNames but none of them seems to work
    ObjectName service = new ObjectName("com.bea:Name=EditService,Type=weblogic.management.mbeanservers.edit.EditServiceMBean");
    and
    connection.getAttribute(service, "JDBCSystemResources");
    Thank you very much for your help.

    I would encourage you to use WLST because it's much easier IMHO. What is your use case?
    But if you must use java, this should get you started:
    package foo;
    import java.util.Hashtable;
    import javax.management.MBeanAttributeInfo;
    import javax.management.MBeanInfo;
    import javax.management.MBeanServerConnection;
    import javax.management.ObjectName;
    import javax.management.remote.JMXConnector;
    import javax.management.remote.JMXConnectorFactory;
    import javax.management.remote.JMXServiceURL;
    public class TestJMX {
         public static void main(String[] args) throws Exception {
              JMXConnector jmxCon = null;
              try {
                   JMXServiceURL serviceUrl = new JMXServiceURL(
                             "service:jmx:t3://localhost:7011/jndi/weblogic.management.mbeanservers.edit");
                   System.out.println("Connecting to: " + serviceUrl);
                   Hashtable env = new Hashtable();
                   env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,
                             "weblogic.management.remote");
                   env.put(javax.naming.Context.SECURITY_PRINCIPAL, "weblogic");
                   env.put(javax.naming.Context.SECURITY_CREDENTIALS, "welcome1");
                   jmxCon = JMXConnectorFactory.newJMXConnector(serviceUrl, env);
                   jmxCon.connect();
                   MBeanServerConnection con = jmxCon.getMBeanServerConnection();
    //               Set<ObjectName> mbeans = con.queryNames(null, null);
    //               for (ObjectName mbeanName : mbeans) {
    //                    System.out.println(mbeanName);
                   System.out.println("***** JDBC System Resources ********" );
                   ObjectName domain = new ObjectName("com.bea:Name=medrec,Type=Domain");
                   ObjectName[] objNames = (ObjectName[]) con.getAttribute(domain, "JDBCSystemResources");
                   System.out.println("JDBCSystemResources");
                   for( ObjectName objName : objNames )
                        System.out.println( objName );
                        MBeanInfo info = con.getMBeanInfo(objName);
                        MBeanAttributeInfo[] attributes = info.getAttributes();
                        for( MBeanAttributeInfo attrInfo : attributes )
                             String name = attrInfo.getName();
                             System.out.println( name + " " + attrInfo.getType() + " " + con.getAttribute(objName, name) );
              } finally {
                   if (jmxCon != null)
                        jmxCon.close();
    }For me that prints:
    <pre>
    Connecting to: service:jmx:t3://localhost:7011/jndi/weblogic.management.mbeanservers.edit
    ***** JDBC System Resources ********
    JDBCSystemResources
    com.bea:Name=MedRecGlobalDataSourceXA,Type=JDBCSystemResource
    Parent javax.management.ObjectName com.bea:Name=medrec,Type=Domain
    Resource javax.management.ObjectName com.bea:Name=MedRecGlobalDataSourceXA,Type=weblogic.j2ee.descriptor.wl.JDBCDataSourceBean,Parent=[medrec]/JDBCSystemResources[MedRecGlobalDataSourceXA],Path=JDBCResource[MedRecGlobalDataSourceXA]
    Type java.lang.String JDBCSystemResource
    CompatibilityName java.lang.String null
    ModuleType java.lang.String null
    SourcePath java.lang.String ./config/jdbc/MedRec-jdbc.xml
    JDBCResource javax.management.ObjectName com.bea:Name=MedRecGlobalDataSourceXA,Type=weblogic.j2ee.descriptor.wl.JDBCDataSourceBean,Parent=[medrec]/JDBCSystemResources[MedRecGlobalDataSourceXA],Path=JDBCResource[MedRecGlobalDataSourceXA]
    DescriptorFileName java.lang.String jdbc/MedRec-jdbc.xml
    Notes java.lang.String null
    Name java.lang.String MedRecGlobalDataSourceXA
    SubDeployments [Ljavax.management.ObjectName; [Ljavax.management.ObjectName;@3219762f
    DeploymentPrincipalName java.lang.String null
    Targets [Ljavax.management.ObjectName; [Ljavax.management.ObjectName;@178aab40
    DeploymentOrder java.lang.Integer 100
    </pre>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • JMX and websphere

    This problem has been posted before:
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0604&L=jmx-forum&P=1531
    But I am still having problems with it. Basically, I have an mbean server set up running on java 1.5. I have a client that can connect to it that is also running java 1.5.
    However, I have a web project (using websphere 6 runtime files) that uses exactly the same code as the client, but fails (jmxc.getMBeanServerConnection() returns null...)
    url = new JMXServiceURL
            ("service:jmx:rmi://localhost:0/jndi/rmi://localhost:9999/server");
            JMXConnectorServer cs =
                 JMXConnectorServerFactory.newJMXConnectorServer(url, null, null);
            ObjectName cntorServerName = ObjectName.getInstance("connectors:protocol=rmi");
            mbs.registerMBean(cs, cntorServerName);
            cs.start();The working cilent and broken client both use this code
    url = new JMXServiceURL("service:jmx:rmi://host/jndi/rmi://localhost:9999/server");
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
          MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();Basically I think the problem is that websphere uses mx4j and my server is using the java 1.5 jmx implementation.
    Anyone have any solutions that dont force me to use mx4j on my server?
    Message was edited by:
    dominicadatia

    Hi Simon,
    This is the piece of code from JDK5:
         MBeanServerConnection mbsc =
             (MBeanServerConnection) rmbscMap.get(delegationSubject);
         if (mbsc != null)
             return mbsc;
         mbsc = new RemoteMBeanServerConnection(delegationSubject);
         rmbscMap.put(delegationSubject, mbsc);
         return mbsc;
            ....Under no circumstance can this return a null Object. It could throw an exception,
    but it can't return null. Whatever classloading issue there may be, it can't return
    a null object.
    If neither the JDK 5 RMIConnector nor MX4J RMIConnector objects can return null,
    it follows that the JMXConnector obtained by the websphere client is none of
    them? Could it be a JMXConnector wrapper or something returned by an alternate
    provider?
    dominicadatia:
    What do you see if you code your client as follows:
         url = new JMXServiceURL("service:jmx:rmi://host/jndi/rmi://localhost:9999/server");
         System.err.println("url="+url);
         JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
         System.err.println("jmxc="+jmxc);
         if (jmxc !=null) System.err.println("jmxc class: "+jmxc.getClass().getName());
         MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
         System.err.println("mbsc="+mbsc);
         if (mbsc!=null) System.err.println("mbsc class: "+mbsc.getClass().getName());-- daniel

Maybe you are looking for