2 Replies Latest reply on Nov 10, 2011 12:52 PM by brianstark

    native management api - read-only access types?

    brianstark

      Hello,

       

      Is there any way to configure JBoss AS 7 to allow an attribute to be read-write instead of just read-only?

       

      I am in the middle of migrating a JBoss 3.2 application to JBoss 7.0.2 and have run into a roadblock with the native management API.

       

      The application in question has its own web-based admin front-end that allows the user to specifiy a different port number for use with the data source URL.  I am trying to set the "connection-url" attribute of the data-source, but I noticed that it has an access-type of "read-only". My code looks like this:

       

             ModelControllerClient client = ModelControllerClient.Factory.create(hostname, port);

             ModelNode op = new ModelNode();

             op.get("operation").set("write-attribute");      

            

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

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

             address.add("data-source", dataSourceName);

            

             op.get("name").set("connection-url");

             op.get("value").set(theURL);

            

             ModelNode returnValue = client.execute(op);

             logger.info("Result: " + returnValue);

       

      I tried making the change via the JBoss Management Console, but also run into the same roadblock. The error message is:

       

      Internal Server Error

      {

          "outcome" => "failed",

          "result" => {"step-1" => {

              "outcome" => "failed",

              "failure-description" => "Attribute connection-url is not writeable",

              "rolled-back" => true

          }},

          "failure-description" => {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => "Attribute connection-url is not writeable"}},

          "rolled-back" => true

      }

       

      I get I can't update something that is marked read-only, but the odd thing is that the "enabled" attribute is also shown to be "read-only", yet I can use the JBoss Management Console to mark a datasource as enabled/disabled.. So, in effect, the JBoss Management Console is working with a "read-write" version of the enabled attribute. How is that possible? The native management API is not very useful for configuring data sources as the majority of the attributes have an access type of "read-only". Am I missing something?

       

      Reference code to describe the datasources:

       

            ModelControllerClient client = ModelControllerClient.Factory.create(hostname, port);

            ModelNode op = new ModelNode();    

            op.get("operation").set("read-resource-description");

            

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

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

                  

            ModelNode returnValue = client.execute(op);

            logger.info("Result: " + returnValue);

       

      thank you,

       

      Brian

        • 1. Re: native management api - read-only access types?
          jaikiran

          Can you try this against latest AS7 night build http://community.jboss.org/thread/167590. A lot of management related issues have been fixed after 7.0.2. Let us know if you still run into that issue.

          • 2. Re: native management api - read-only access types?
            brianstark

            Hi Jaikiran,

             

            I tried the latest nightly build (#1097), and the problem I had run into is now working. To test, I added my data source definitions to the standalone.xml file, started up the nightly build then ran my client-side test driver against it. I was able to read the connection-url, write a new value, and upon shutting down JBoss, I was able to confirm that the newly updated URL was indeed written back to the standalone.xml file.

             

            A quick scan of the resource description for the data-source shows that most, if not all of the attributes are now marked as read-write, which is what I was hoping for.

             

             

            Brian