Java Spring Framework jmx managed annotation @ManagedAttribute not showing method in MBeanServerConnection/Jconsole/Visual vm/bean list

StackOverflow https://stackoverflow.com/questions/18373970

Question

Ive Added Spring annotation's to my code but when connecting via visual vm the method "myExample()" isn't showing in the JMX bean list

My code :

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Component;


@Component
@ManagedResource
public class MyClass {

   @Autowired
   private Example exampleService;

   @ManagedAttribute
   public String myExample() {
      return exampleService.getSomething().toString();
   }
} 

any idea why this is happening ?

Was it helpful?

Solution

You should use @ManagedOperation instead. @ManagedAttribute is for a getter / setter methods only.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top