How to show msg when attribute change fails?

  • The Cuillivo
    The Cuillivo

    I’m trying to show an error message in JManage when an mbean attribute change raises an exception.

    For example, when you run mbean operations through JManage, you can return a String that will be shown as the operation output. Using this mechanism, when something wrong happens with the invocation, you can give some details using the output. But, when you change an mbean attribute, there’s no such “output”. So, when an attribute is changed and an unsuitable value is provided (like when you expect a number and a letter is entered), you don’t have the same facility to show some kind of error message.

    Any suggestions in how I can display a descriptive text about the failed attribute change through JManage and the JMX API?

    Thanks in advance.

    • Rakesh Kalra
      Rakesh Kalra

      Unfortunately, JMX API doesn't really cover validation errors.

      I think throwing an exception may not be a good idea from setXXX() method. The best thing may be to silently ignore such a set operation.

      jManage should be enhanced to look at the old and new attribute values, and then show an error message if the attribute value didn't change.

      What are you thoughts on this?


      • The Cuillivo
        The Cuillivo

        Yes, I think you’re right. I’ll better handle the error without throwing the exception. Though, a workaround to the message displaying problem could be having a read-only String attribute in all your Mbeans that shows some kind of status message related to the last change it was made on the Mbean. It’s not very elegant but it’s a way to overcome the lack of a proper error displaying functionality.

        Having that feature you talked about in jManage would be great. Any future plans to add it?

        Thanks a lot for your help.

        All the best,