Bug 958217

Summary: Unable to call Stateless bean methods from Singleton PreDestroy callback
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Thomas Segismont <tsegismo>
Component: EJBAssignee: Jaikiran Pai <jpai>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: dimitris
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-05-15 11:50:16 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:
Bug Depends On:    
Bug Blocks: 957689, 963167    
Attachments:
Description Flags
Sample application none

Description Thomas Segismont 2013-04-30 15:27:22 UTC
Description of problem:
Using Singleton bean PreDestroy callback is a common way to perform tasks when server goes down. But calling Stateless bean methods in the callback code fails with the following error:

javax.ejb.EJBException: JBAS014559: Invocation cannot proceed as component is shutting down 

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

How reproducible:
Always

Steps to Reproduce:
1. Start EAP 6.1 and deploy an application with a Singleton bean calling a Stateless bean method in its PreDestroy callback
2. Stop EAP 6.1
  
Actual results:
Server shows an error "javax.ejb.EJBException: JBAS014559: Invocation cannot proceed as component is shutting down" and stops

Expected results:
Server calls Stateless bean method and stops.

Additional info:

Full stack trace
http://pastebin.test.redhat.com/139645

The error message shown was introduced in this pull request:
https://github.com/wildfly/wildfly/pull/1889

Comment 1 Thomas Segismont 2013-04-30 15:31:03 UTC
Created attachment 741906 [details]
Sample application

Added sample application showing the problem

Comment 2 Jaikiran Pai 2013-05-15 11:50:16 UTC
As explained in an internal mail thread, you'll have to add a @DependsOn annotation on the singleton bean to depend on the stateless bean:

@Singleton
@Startup
@javax.ejb.DependsOn("StatelessBean") // depend on the stateless bean
public class SingletonBean {

....
  @PreDestroy
    public void shutdown() {
        System.out.println("###############################");
        System.out.println("SingletonBean.shutdown");
        System.out.println("###############################");
        statelessBean.doSomething();
    }
}