Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Callback method @Predestroy not called when Jboss server stopped

 
Ranch Hand
Posts: 50
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote this simple Stateless Session bean example (taken from EJB 3.1 Cookbook). When the bean method computeVolume is invoked (through servlet) I can see the method with @PostConstruct being called, but when I stop the server (Jboss AS 7.1 Final) , the print statement in method with @PreDestroy is not called.
Is it normal, from what I understand is this method should be called when a bean is destroyed , which will happen when the server shuts down. Why in that case am I not seeing this being called?



 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you try this against WildFly 8.1.0.Final http://wildfly.org/downloads/ (JBoss AS has been renamed to WildFly)?
 
Ranch Hand
Posts: 160
IntelliJ IDE VI Editor Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you stop the server? If it shuts down cleanly (via a shutdown command) I would expect it to work, but if you just kill the process your callback method probably won't get called.
 
Pallavi Sadit
Ranch Hand
Posts: 50
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Riaan,
I am stopping the server, not killing it. I am using Eclipse IDE and starting and stopping the server from there, can it make a difference?

Jaikiran,
I am yet to try out Wildfly8.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I remember, there was a bug in this area in 7.1.1.Final of JBoss AS. That's why I recommend trying out WildFly 8 latest release.
 
Pallavi Sadit
Ranch Hand
Posts: 50
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaikiran,
I tried the same example with the Wildfly 8.0.0 Final and it worked as expected. Both the @PostConstruct and @PreDestroy methods are called, in-fact I didn't even need to shutdown server, the @PreDestroy method was called immediately after the call is returned from the method invoked from servlet.
Thanks for your help.
 
I can't beleive you just said that. Now I need to calm down with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic