Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Bean's destroy method not invoked when kernel is shut down
Bean's destroy method not invoked when kernel is shut down [message #749397] Tue, 25 October 2011 07:40 Go to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-SchwartzFriend
Messages: 448
Registered: July 2009
Senior Member
Hello everyone.

I am creating a Spring bean declaratively with a "destroy-method" attribute defined in it. When I shut the Virgo kernel down (using the standard script), however, this method is not invoked. Why is that? What do I have to do?

I have also tried to register an ApplicationListener for ApplicationContextEvents, listening for ContextStoppedEvents specifically, but the call back method is never invoked either when the server is shut down.

TIA,
B.

[Updated on: Tue, 25 October 2011 08:28]

Report message to a moderator

Re: Bean's destroy method not invoked when kernel is shut down [message #749847 is a reply to message #749397] Tue, 25 October 2011 13:29 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
I don't know if this helps, but we use an ApplicationListener which is, we assume, driven during shutdown. You might like to verify this using a "suspend VM" breakpoint. See here in OpenGrok.
Re: Bean's destroy method not invoked when kernel is shut down [message #749848 is a reply to message #749847] Tue, 25 October 2011 13:29 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Duplicate comment deleted.

[Updated on: Tue, 25 October 2011 13:30]

Report message to a moderator

Re: Bean's destroy method not invoked when kernel is shut down [message #749861 is a reply to message #749847] Tue, 25 October 2011 13:37 Go to previous messageGo to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-SchwartzFriend
Messages: 448
Registered: July 2009
Senior Member
Hi Glyn.

As my second sentence in my original message states, I have tried that route too and my breakpoint in the callback method is never exercised.
Re: Bean's destroy method not invoked when kernel is shut down [message #749865 is a reply to message #749861] Tue, 25 October 2011 13:39 Go to previous messageGo to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-SchwartzFriend
Messages: 448
Registered: July 2009
Senior Member
Hi Glyn. No cigar, I'm afraid.

I just tried implementing the same kind of listener as in your example (I was originally listening for type ContextStoppedEvent explicitly), but the call back still does not get invoked.

Any alternative you can think of?

What I simply want to do when Virgo is shutting down is remove bundles from the pickup directory that I deposited there earlier.

Thanks,
B.

[Updated on: Tue, 25 October 2011 14:06]

Report message to a moderator

Re: Bean's destroy method not invoked when kernel is shut down [message #753424 is a reply to message #749865] Thu, 27 October 2011 08:22 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Sorry for the late reply - I forgot to subscribe to the thread (shame respondents aren't automatically subscribed, isn't it?).

One brute force way is to detect shutdown using a synchronous bundle listener as here.

[Updated on: Thu, 27 October 2011 08:23]

Report message to a moderator

Re: Bean's destroy method not invoked when kernel is shut down [message #753465 is a reply to message #753424] Thu, 27 October 2011 11:38 Go to previous messageGo to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-SchwartzFriend
Messages: 448
Registered: July 2009
Senior Member
Fantastic, Glyn, thanks!

Seems like a rather last ditch way to do it, but if all else fails...

Doesn't it seem like a bug to you though? Surely if the container is shut down, the declared destroy method of all instantiated beans should be invoked. Do you agree?

The other (probably silly) issue I face is that, despite my attempts to delete the plan file from the pickup directory (in other cases too, not just when I shut down), the delete operation fails presumably because the file is locked by the running Virgo related process. Any work around that one?

Thanks again,
B.

[Updated on: Thu, 27 October 2011 11:41]

Report message to a moderator

Re: Bean's destroy method not invoked when kernel is shut down [message #753467 is a reply to message #753465] Thu, 27 October 2011 11:41 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Could be a bug, but we'd need to spend some time analysing the behaviour to see what is feasible given the various components involved. Would you care to raise a bug and attach a trivial example which reproduces the problem?
Re: Bean's destroy method not invoked when kernel is shut down [message #753472 is a reply to message #753467] Thu, 27 October 2011 12:19 Go to previous message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-SchwartzFriend
Messages: 448
Registered: July 2009
Senior Member
Will create an example and raise a bug in a couple of days, thanks.

What about the other issue (admittedly not strictly on topic, but as long as I have your ear, Glyn... Twisted Evil )

Quote:

The other (probably silly) issue I face is that, despite my attempts to delete the plan file from the pickup directory (in other cases too, not just when I shut down), the delete operation fails presumably because the file is locked by the running Virgo related process. Any work around that one?
Previous Topic:Service referencing
Next Topic:bundle "org.eclipse.virgo.configuration.properties" not found in virgo 3.0.1.RELEASE
Goto Forum:
  


Current Time: Thu Apr 18 22:08:54 GMT 2024

Powered by FUDForum. Page generated in 0.02275 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top