1

I have a simple third party object - a DTO with about 10+ public fields only (it get filled as an atomic operation). I would like to be able to monitor it in JConsole without writing a lot of boilerplate code.

I tried to:

  • Use MXBean - got an exception (NotCompliantMBeanException)
  • Convert the DTO to String using reflection-based utility library like apache.common.lang3.ReflectionToStringBuilder - works, but does not look good since JConsole does not support multi-line strings well, plus it is not efficient.

Any other suggestions?

1 Answer 1

0

It would be helpful if you posted you failing MXBean code. Typically, you would just need to define a DTOMXBean interface, make the DTO implement it and then register the DTO. (It sounds like a weird lifecycle for a DTO since they're usually fairly transient, but that's a topic for a different question).

Keep in mind that the MXBean attributes should not return values of types not defined in javax.management.openmbean.OpenType.ALLOWED_CLASSNAMES_LIST, otherwise you will get a NonCompliant exception. If you must expose types that cannot be represented as one of those types, you will need to define new composite types to expose them as.

1
  • My MXBean is not the DTO but a container class. For example: I monitor an instance of the class "MyService". MyService contains a complex field (the DTO) of type "MemoryUsage" which is exposed via MyServiceMXBean interface. MemoryUsage has few public integer fields. I am not able to show MemoryUsage inner fields in JConsole.
    – dux2
    Sep 11, 2014 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.