Donatas Ciuksys created TOMEE-445:
-------------------------------------
Summary: @RequestScoped @Stateful EJB beans are not destroyed
after request completes
Key: TOMEE-445
URL: https://issues.apache.org/jira/browse/TOMEE-445
Project: TomEE
Issue Type: Bug
Affects Versions: 1.5.0
Environment: Windows 7 x64; Oracle JDK 1.7.0_07;
tomee-web-profile-1.5.0.zip
Reporter: Donatas Ciuksys
1. Create simple JSF+CDI+EJB application consisting of one JSF page and one EJB
component:
index.xhtml:
...
<h:body>
Current real date is: #{dateBean.currentDate()}
</h:body>
</html>
EJB: DateBean.java:
@Named
@RequestScoped
@Stateful
public class DateBean {
@PostConstruct
private void init() {
System.out.println("INIT: " + this);
}
@PreDestroy
private void die() {
System.out.println("DIE: " + this);
}
public String currentDate() {
System.out.println("Method was called...");
return "" + new Date();
}
}
2. Run the application. EJB method works OK, the current date is getting
printed. Refresh browser window several times, Tomee log file will print this:
INIT: beans.DateBean@1ac52c5
Method was called...
INIT: beans.DateBean@792217
Method was called...
INIT: beans.DateBean@1438814
Method was called...
Method annotated with @PreDestroy never gets called.
3. Remove annotation @Stateful (thus EJB bean becomes simple CDI bean), try
again.
This time each INIT log message is followed by DIE message.
Conclusion: @RequestScoped + @PreDestroy is working on CDI beans, but not on
EJB beans.
--
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