A small correction to my note.
Predestroy is being called when I called the method having @Remove annotation. However, when JBOSS is shutdown gracefully, I don't see the predestroy method being called.
This is just jboss. Dont think they support standards or should I say they have their own standards :).
Spent a few days on this & gone back to ejb 2.1.
See Bill's comment in
In areas where the specification lacks explicitly-defined behavior, it is the responsibility of the vendor to fill in the gaps.
It is the intention of JBoss to support all standards and ensure that applications remain as portable across implementations as possible.
Spec 4.3.11 and 4.4, Figure 5 do not dictate that the PreDestroy callback be called on undeployment. In fact, 4.4.3 says:
The Bean Provider cannot assume that the container will always invoke the PreDestroy lifecycle callback interceptor method(s) (or ejbRemove method) for a session bean instance.
Is it possible for you to use "destroy" of an @Service/MBean/Singleton to fulfill your requirements?