users@glassfish.java.net

_at_PreDestroy method in web service not called when web app undeployed?

From: <glassfish_at_javadesktop.org>
Date: Fri, 04 Jul 2008 09:23:44 PDT

I have a web service that needs to do some cleanup (shut down a background thread). So I implemented a method annotated with @PreDestroy. Unfortunately, the method is never called. I would have expected it to be called when the web service application is undeployed or disabled, but it is not.

This is an extremely simple JAX-WS web service written in Netbeans 6.1 and deployed to Glassfish v3.

I looked at the specs, and it's a bit vague about exactly when PreDestroy methods are to be called. The language says "Should" rather than "Must".

Question: Is there a reliable way I can get my method called whenever the app is undeployed or redeployed? Note that my @PostConstruct method *does* get called!
[Message sent by forum member 'duncant' (duncant)]

http://forums.java.net/jive/thread.jspa?messageID=284415