Bug 884684

Summary: EJB @PreDestroy not called when AS/EAP stopped
Product: OpenShift Online Reporter: Bill DeCoste <wdecoste>
Component: ContainersAssignee: Dan Mace <dmace>
Status: CLOSED NOTABUG QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 2.xCC: chunchen, dmcphers, mmcgrath, sannam, xtian
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-09 19:41:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Lifecycle demo code none

Description Bill DeCoste 2012-12-06 14:51:42 UTC
Description of problem:
EJB @PreDestroy not called when AS/EAP stopped

Version-Release number of selected component (if applicable):


How reproducible:
100%


Steps to Reproduce:
1. Create AS/EAP app
2. Deploy app with EJBs w/@PreDestroy method
3. Stop AS/EAP
  
Actual results:
@PreDestroy not called


Expected results:
@PreDestroy should be called


Additional info:
Likely caused by killing the process tree vs calling shutdown

Comment 2 Bill DeCoste 2013-02-21 00:39:08 UTC
Use kill -9 instead of kill - TERM if graceful shutdown fails

Comment 3 Mike McGrath 2013-06-24 19:34:16 UTC
Moved during bug triage meeting

Comment 4 Dan Mace 2013-07-09 19:37:38 UTC
Created attachment 771201 [details]
Lifecycle demo code

Comment 5 Dan Mace 2013-07-09 19:41:00 UTC
I'm closing this issue as NOTABUG, and have attached example code which can be added to a jbossas-7 application demonstrating the lifecycle methods. The code provides a LifecycleDemo class which is a @Singleton/@Startup EJB.

When the example code is built and deployed, the following output will appear in the JBoss server.log during startup, demonstrating @PostConstruct:

2013/07/09 15:34:41,027 INFO  [stdout] (MSC service thread 1-1) !!!!!!!!!!! in postconstruct

When an `rhc app stop` is issued to the application, the following output will appear in the JBoss boot.log demonstrating @PreDestroy:

15:34:59,821 INFO  [stdout] !!!!!!!!!!! in predestroy

The jbossas-7 cartridge issues a SIGTERM to the container for shutdown, which is equivalent to using the JBoss CLI 'shutdown' command. This is a graceful shutdown, and the lifecycle is honored in both cases.