[jboss-jira] [JBoss JIRA] (AS7-5911) Statefull session beans are not (always) properly destroyed/disposed
Stuart Douglas (JIRA)
jira-events at lists.jboss.org
Mon Jan 21 18:43:21 EST 2013
[ https://issues.jboss.org/browse/AS7-5911?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stuart Douglas updated AS7-5911:
--------------------------------
Component/s: EJB
(was: EE)
(was: CDI / Weld)
The problem here is that if the EJB is using a clustered cache then it should not be destroyed, as it can still be used from another instance.
If we were to implement this that would mean a different behaviour for clustered and non-clustered EJB's, which I am not sure is a good idea.
> Statefull session beans are not (always) properly destroyed/disposed
> --------------------------------------------------------------------
>
> Key: AS7-5911
> URL: https://issues.jboss.org/browse/AS7-5911
> Project: Application Server 7
> Issue Type: Bug
> Components: EJB
> Affects Versions: 7.1.0.Final
> Reporter: Martin Centner
> Assignee: Stuart Douglas
> Attachments: test.war
>
>
> Statefull session beans are not always properly disposed when undeploying the application or stopping the application server.
> To reproduce this I've created the following (Arquillian) test.
> It contains a simple Java bean:
> @Typed
> public class TestBean {
> private String message;
> public String getMessage() {
> return message;
> }
> public void setMessage(String message) {
> this.message = message;
> }
>
> }
> A corresponding producer:
> public class TestBeanProducer {
>
> private final Logger log = LoggerFactory.getLogger(getClass());
>
> @Produces
> public TestBean produceTestBean() {
> log.info("produceTestBean()");
> TestBean testBean = new TestBean();
> testBean.setMessage("Hello World!");
> return testBean;
> }
>
> public void disposeTestBean(@Disposes TestBean testBean) {
> log.info("disposeTestBean()");
> testBean.setMessage(null);
> }
> }
> And finally the statefull session bean:
> @Stateful
> public class TestStatefullSessionBean {
> private final Logger log = LoggerFactory.getLogger(getClass());
>
> @Inject
> transient TestBean testBean;
>
> @PostConstruct
> public void init() {
> log.info("init()");
> }
>
> public void test() {
> log.info(testBean.getMessage());
> }
>
> @PreDestroy
> public void cleanUp() {
> log.info("cleanUp()");
> }
>
> }
> When I run this as Arquillian test in the container I get the following expected behavior:
> 21:13:13,668 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "test.war"
> 21:13:14,083 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016002: Processing weld deployment test.war
> 21:13:14,084 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named TestStatefullSessionBean in deployment unit deployment "test.war" are as follows:
> java:global/test/TestStatefullSessionBean!at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean
> java:app/test/TestStatefullSessionBean!at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean
> java:module/TestStatefullSessionBean!at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean
> java:global/test/TestStatefullSessionBean
> java:app/test/TestStatefullSessionBean
> java:module/TestStatefullSessionBean
> 21:13:14,106 INFO [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016005: Starting Services for CDI deployment: test.war
> 21:13:14,118 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016008: Starting weld service for deployment test.war
> 21:13:14,216 INFO [org.jboss.web] (MSC service thread 1-4) JBAS018210: Registering web context: /test
> 21:13:14,232 INFO [org.jboss.as.server] (management-handler-thread - 11) JBAS018559: Deployed "test.war"
> 21:13:14,872 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (http--0.0.0.0-8080-1) produceTestBean()
> 21:13:14,873 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (http--0.0.0.0-8080-1) init()
> 21:13:14,881 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (http--0.0.0.0-8080-1) Hello World!
> 21:13:14,884 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (http--0.0.0.0-8080-1) cleanUp()
> 21:13:14,884 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (http--0.0.0.0-8080-1) disposeTestBean()
> 21:13:14,918 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016009: Stopping weld service for deployment test.war
> 21:13:14,939 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment test.war in 26ms
> 21:13:14,951 INFO [org.jboss.as.repository] (management-handler-thread - 12) JBAS014901: Content removed from location /Users/mcentner/java/jboss-as-7.1.1.Final/standalone/data/content/5b/20bd9c42eb5e656c3f2b396125de45636a0b8a/content
> 21:13:14,952 INFO [org.jboss.as.server] (management-handler-thread - 12) JBAS018558: Undeployed "test.war"
> However, when I deploy the "test.war" ...
> 21:31:24,792 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "test.war"
> 21:31:24,830 INFO [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016002: Processing weld deployment test.war
> 21:31:24,831 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named TestStatefullSessionBean in deployment unit deployment "test.war" are as follows:
> java:global/test/TestStatefullSessionBean!at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean
> java:app/test/TestStatefullSessionBean!at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean
> java:module/TestStatefullSessionBean!at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean
> java:global/test/TestStatefullSessionBean
> java:app/test/TestStatefullSessionBean
> java:module/TestStatefullSessionBean
> 21:31:24,858 INFO [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016005: Starting Services for CDI deployment: test.war
> 21:31:24,869 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016008: Starting weld service for deployment test.war
> 21:31:24,929 INFO [org.jboss.web] (MSC service thread 1-8) JBAS018210: Registering web context: /test
> 21:31:24,941 INFO [org.jboss.as.server] (HttpManagementService-threads - 3) JBAS018559: Deployed "test.war"
> ... and click around in the JBoss AS7 Console (section "Naming") ...
> 21:43:01,763 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 4) produceTestBean()
> 21:43:01,764 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 4) init()
> 21:43:01,766 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 4) produceTestBean()
> 21:43:01,767 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 4) init()
> 21:43:01,769 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 4) produceTestBean()
> 21:43:01,770 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 4) init()
> 21:43:01,771 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 4) produceTestBean()
> 21:43:01,772 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 4) init()
> 21:43:01,778 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 4) produceTestBean()
> 21:43:01,778 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 4) init()
> 21:43:01,781 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 4) produceTestBean()
> 21:43:01,781 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 5) produceTestBean()
> 21:43:01,782 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 4) init()
> 21:43:01,782 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 5) init()
> 21:43:01,784 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 4) produceTestBean()
> 21:43:01,784 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 5) produceTestBean()
> 21:43:01,784 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 4) init()
> 21:43:01,785 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 5) init()
> 21:43:01,786 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 4) produceTestBean()
> 21:43:01,787 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 4) init()
> 21:43:01,792 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 5) produceTestBean()
> 21:43:01,793 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 5) init()
> 21:43:01,795 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 5) produceTestBean()
> 21:43:01,796 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 5) init()
> 21:43:01,803 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 5) produceTestBean()
> 21:43:01,804 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 5) init()
> 21:43:01,805 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 5) produceTestBean()
> 21:43:01,806 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 5) init()
> 21:43:01,808 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 5) produceTestBean()
> 21:43:01,809 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 5) init()
> 21:43:01,812 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestBeanProducer] (HttpManagementService-threads - 5) produceTestBean()
> 21:43:01,813 INFO [at.gv.stmk.zza2.test.jboss.jcr.TestStatefullSessionBean] (HttpManagementService-threads - 5) init()
> ... a number of instances of the TestBean are produced. When "test.war" is now undeployed (through the console) ...
> 21:45:48,745 INFO [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016009: Stopping weld service for deployment test.war
> 21:45:48,755 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment test.war in 15ms
> 21:45:48,763 INFO [org.jboss.as.server] (HttpManagementService-threads - 6) JBAS018558: Undeployed "test.war"
> ... none of the generated instances is being destroyed / disposed.
> In our real use case this prevents us from a clean shut down of a Java Content Repository.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list