9 Replies Latest reply on Dec 14, 2011 3:23 AM by duanxz

    JMX-based monitoring  the jbossAS7 database connection pool

    duanxz

      in jboss-as-web-7.0.2.Final

      code:
      RMIAdaptor server = null;
      server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor");
      ObjectName name=new ObjectName("jboss:service=JNDIView");
      Object result = server.invoke(name, "listXML", null, null);
      ....


      Error info:javax.naming.NameNotFoundException: jmx/rmi/RMIAdaptor -- service jboss.naming.context.java.jmx.rmi.RMIAdaptor

       

      PS:This code can run on earlier versions of the jboss, but in the jboss-as-web-7.0.2.Final it appears this error.

      Any help with this will be greatly appreciated.

        • 1. Re: JMX-based monitoring  the jbossAS7 database connection pool
          heiko.braun

          AS 7 ships with it's own management layer and does not expose managemnt operations and atributes through JMX anymore. In order to retrieve the datasource information, you would need to rely on the detyped description, as described here.

           

          An example does look like this (Using the CLI):

           

          Laika:jboss-as-7.1.0.Alpha2-SNAPSHOT hbraun$ ./bin/jboss-admin.sh --connect
          Connected to standalone controller at localhost:9999
          
          [standalone@localhost:9999 /] /subsystem=datasources/data-source=java\:jboss\/datasources\/ExampleDS:read-resource(include-runtime=true)
          {
              "outcome" => "success",
              "result" => {
                  "ActiveCount" => "0",
                  "AvailableCount" => "20",
                  "AverageBlockingTime" => "0",
                  "AverageCreationTime" => "0",
                  "CreatedCount" => "0",
                  "DestroyedCount" => "0",
                  "MaxCreationTime" => "0",
                  "MaxUsedCount" => "0",
                  "MaxWaitCount" => "0",
                  "MaxWaitTime" => "0",
                  "PreparedStatementCacheAccessCount" => "0",
                  "PreparedStatementCacheAddCount" => "0",
                  "PreparedStatementCacheCurrentSize" => "0",
                  "PreparedStatementCacheDeleteCount" => "0",
                  "PreparedStatementCacheHitCount" => "0",
                  "PreparedStatementCacheMissCount" => "0",
                  "TimedOut" => "0",
                  "TotalBlockingTime" => "0",
                  "TotalCreationTime" => "0",
                  [...]
              }
          }

           

           

          But you can do the same thing using the Java API.

          • 2. Re: JMX-based monitoring  the jbossAS7 database connection pool
            duanxz

            Hi Braun,
            Thanks for Response.
            but two things is not really clear to me.
            1、In order to retrieve the datasource information,
            To parse the standalone.xml located in jboss-as-web-7.0.2.Final\standalone\configuration file system  to get data source information?
            in standalone.xml Contains the following information:
            ================================================================================================
            <datasource jndi-name="abc" pool-name="H2DS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
                                <connection-url>
                                    jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
                                </connection-url>
                                <driver>
                                    h2
                                </driver>
                                <pool>
                                    <prefill>
                                        false
                                    </prefill>
                                    <use-strict-min>
                                        false
                                    </use-strict-min>
                                    <flush-strategy>
                                        FailingConnectionOnly
                                    </flush-strategy>
                                </pool>
                                <security>
                                    <user-name>
                                        sa
                                    </user-name>
                                    <password>
                                        sa
                                    </password>
                                </security>
                            </datasource>
            ================================================================================================
            2、use “Detyped Description of the AS 7 Management Model" to  retrieve the datasource information.
            like this:
            ==================================
            ModelNode op = new ModelNode();
            op.get("operation").set("read-resource-description");
            op.get("recursive").set(true);
            op.get("operations").set(true);
            ModelNode address = op.get("address");
            address.add("subsystem", "web");
            address.add("connector", "http");
            ==================================
            if i want to get all like "<datasource jndi-name =" abc "pool-name =..." node data source name, how to modify the code?

            Could you please help me ?


            Thanks a lot,

            duanxz

            • 3. Re: JMX-based monitoring  the jbossAS7 database connection pool
              heiko.braun

              Yes, the second approach. You can request all needed information through either a Java or HTTP protocol. This Wiki page explains the format of such a request (adressing, parameters, etc):

               

               

              - http://community.jboss.org/wiki/FormatOfADetypedOperationRequest

               

               

              General information can be found here:

               

              - https://docs.jboss.org/author/display/AS71/Admin+Guide

              • 4. Re: JMX-based monitoring  the jbossAS7 database connection pool
                duanxz

                Hi Braun,
                Thanks a lot for your help and tips.
                I want to read All datasources,according to your advice,  my code is as follows, but I have trouble converting the CLI to Java code:
                ================================================
                ===CLI command:
                [standalone@192.0.0.204:9999 subsystem=datasources] :read-children-resources(child-type=data-source)
                {
                    "outcome" => "success",
                    "result" => {
                        "abc" => {
                ....
                ....
                ===java code:
                ModelControllerClient.Factory factory = new ModelControllerClient.Factory();
                ModelControllerClient client = factory.create(InetAddress.getByName("192.0.0.204"), 9999);
                ModelNode op  = new ModelNode();
                op.get("operation").set("read-children-resources");
                op.get("recursive").set(true);
                op.get("operations").set(true);
                ModelNode address = op.get("address");
                address.add("subsystem", "datasources");
                address.add("datasource", "jndi-name");
                System.out.println(op);
                try {
                ModelNode returnVal = client.execute(op);
                System.out.println(returnVal);
                } catch (IOException ie) {
                // TODO Auto-generated catch block
                ie.printStackTrace();
                }
                ================================================
                error trace:
                ------------------------------------------------
                {
                     "outcome" => "failed",
                     "failure-description" => "No handler for operation read-child ren-resources at address [

                     (\"subsystem\" => \"datasources\"),
                     (\"datasource\" => \"jndi-name\")
                ]",
                     "rolled-back" => true
                }
                -------------------------------------------------
                I don't know with the ModelNode parameter Usage.
                Could you please help me with this one?
                Thanks a lot,

                duanxz

                • 5. Re: JMX-based monitoring  the jbossAS7 database connection pool
                  duanxz

                  Hi Braun,

                   

                  I had get Correct wording.

                  op.get("address").add("profile", "default");  this seems to be used in mode domain management,when use in standalone mode will generate an error as follow:

                  ===========================

                  {
                       "outcome" => "failed",
                       "failure-description" => "No handler for operation read-children-resources at address [
                       (\"profile\" => \"default\"),
                       (\"subsystem\" => \"datasources\")
                  ]",
                       "rolled-back" => true
                  }

                  ===========================

                   

                  Could you please help me with "profile" usage.

                   

                  Thanks a lot,

                   

                  duanxz

                  • 6. Re: JMX-based monitoring  the jbossAS7 database connection pool
                    beve

                    Hi,

                    ModelNode address = op.get("address");

                    address.add("subsystem", "datasources");

                    address.add("datasource", "jndi-name");

                     

                    If you change the value of the string "jndi-name" to the name of the datasource I think it should work. For example:

                     

                    ModelNode address = op.get("address");
                    address.add("subsystem", "datasources");
                    address.add("datasource", "MyDS");
                    
                    

                     

                    Regards,

                     

                    /Daniel

                    1 of 1 people found this helpful
                    • 7. Re: JMX-based monitoring  the jbossAS7 database connection pool
                      duanxz

                      hi,Daniel

                      Thanks for you tips and help.

                       

                      Now i have another two things not understand.

                      first:in ModelControllerClient client = factory.create(InetAddress.getByName("192.0.0.204"), 9999);

                           The IP address "192.0.0.204" how to get it from JbossAS7 system?

                      second:

                      I saw some demo like this:

                      ====================================

                      ModelNode address = op.get("address");
                      address.add("subsystem", "datasources");

                      address.add("profile", "default");

                      address.add("datasource", "MyDS");

                      ====================================

                      address.add("profile", "default"); this seems to be used in mode domain management,when use in standalone mode  will generate an error.

                      How can the two modes at the same time to use it???

                       

                      Could you please help me with this usage.

                       

                      Thanks a lot,

                       

                      Regards

                       

                      duanxz


                       



                      • 8. Re: JMX-based monitoring  the jbossAS7 database connection pool
                        duanxz

                        hi,Braun

                         

                        When i Using the CLI to get datasource encountered a problem,when use JBoss Security Manage in native-interface,

                         

                        ModelControllerClient client = factory.create(InetAddress.getByName("192.0.0.204"), 9999);

                         

                        how to put the user/password into above code‘s.

                         

                        Please help me this,Thanks.

                         

                         

                        Regards,

                        duanxz

                        • 9. Re: JMX-based monitoring  the jbossAS7 database connection pool
                          duanxz

                          Hi,Braun


                          when i used “Detyped Description of the AS 7 Management Model" retrieve jboss datasource,on jbossAS7 console appear the follow ERROR,

                           

                          this ERROR message want to tell us what?And what impact it?

                           

                          =========================================================================================================
                          00:40:53,125 INFO  [org.jboss.remoting] (pool-4-thread-1) JBoss Remoting version 3.2.0.Beta2
                          00:40:53,207 INFO  [org.xnio] (pool-4-thread-1) XNIO Version 3.0.0.Beta3
                          00:40:53,301 INFO  [org.xnio.nio] (pool-4-thread-1) XNIO NIO Implementation Version 3.0.0.Beta3
                          00:40:55,219 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 1) JBREM00200: Remote connection failed: java.io.IOException: Message data for non-existent channel
                          00:41:06,290 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 5) JBREM00200: Remote connection failed: java.io.IOException: Window open for non-existent channel
                          00:41:06,606 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 6) JBREM00200: Remote connection failed: java.io.IOException: Window open for non-existent channel
                          00:41:17,287 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 8) JBREM00200: Remote connection failed: java.io.IOException: Window open for non-existent channel
                          00:41:20,770 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 13) JBREM00200: Remote connection failed: java.io.IOException: Window open for non-existent channel
                          00:41:29,809 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 16) JBREM00200: Remote connection failed: java.io.IOException: Window open for non-existent channel
                          00:41:31,273 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 17) JBREM00200: Remote connection failed: java.io.IOException: Message data for non-existent channel
                          00:41:40,941 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 23) JBREM00200: Remote connection failed: java.io.IOException: Window open for non-existent channel
                          00:41:46,471 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 30) JBREM00200: Remote connection failed: java.io.IOException: Window open for non-existent channel
                          00:41:49,686 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 32) JBREM00200: Remote connection failed: java.io.IOException: Message data for non-existent channel
                          00:41:50,059 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 33) JBREM00200: Remote connection failed: java.io.IOException: Message data for non-existent channel
                          00:41:51,800 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 35) JBREM00200: Remote connection failed: java.io.IOException: Message data for non-existent channel
                          00:41:51,941 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 36) JBREM00200: Remote connection failed: java.io.IOException: Window open for non-existent channel
                          00:41:51,950 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 1) JBREM00200: Remote connection failed: java.io.IOException: Connection reset by peer
                          00:41:52,188 ERROR [org.jboss.remoting.remote] (XNIO NIO Read 37) JBREM00200: Remote connection failed: java.io.IOException: Message data for non-existent channel

                          ....
                          =========================================================================================================


                          Any help is appreciate,thanks a lot!

                          Regard,
                          duanxz