Bug 958217 - Unable to call Stateless bean methods from Singleton PreDestroy callback
Summary: Unable to call Stateless bean methods from Singleton PreDestroy callback
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: EJB
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: ---
Assignee: Jaikiran Pai
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 957689 963167
TreeView+ depends on / blocked
 
Reported: 2013-04-30 15:27 UTC by Thomas Segismont
Modified: 2013-10-23 23:02 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-05-15 11:50:16 UTC
Type: Bug


Attachments (Terms of Use)
Sample application (5.03 KB, application/octet-stream)
2013-04-30 15:31 UTC, Thomas Segismont
no flags Details

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();
    }
}


Note You need to log in before you can comment on or make changes to this bug.