To try and further explain what we are attempting to do, we basically have the following case:
1. An EntityListener is listening for when an entity is persisted, updated, or deleted
2. When that happens, the EntityListener wants to evaluate some other DB state to make a decision. To make that decision we had wanted to use an EntityManager to lookup the values in the DB that we needed.
3. Based on the evaluation in step 2, we wanted to do a call to a JMX Service that we have, which happens to be running in the same instance of JBoss in this case, to do some further work. This service has some threading in it and has its own references to some EJB3 Session beans.
Our questions are:
1. Is it true that you can not access an EntityManager from an EntityListener?
2. If the answer to question one is true, what is the correct way to relatively generically trigger some work to be done when the DB changes (assuming that work requires access to other information in the DB)?
3. It is our understanding that the MBean spec allows threading. Since EJBs are not supposed to spawn their own threads does this mean that you should really never access a MBean from within a EJB?
Thanks a lot.