I have an MBean that I would like to do something each time a certain EJB3 Entity bean of mine is changed. So I created a listener annotated with PrePersist, PreUpdate and PreRemove. The idea is this listener then uses a reference to my MBean to do something. But I have having difficulty getting the MBean into the listener.
I have tried injecting it and have tried getting it using the javax.management api but it appears that the listener methods are invoked on deployment before the MBean is bound, resulting in name not bound or null pointer exceptions.
How should I get the MBean instance into my entity bean life-cycle listener?