Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5.0
-
None
-
None
-
Windows 7 x64; Oracle JDK 1.7.0_07; tomee-web-profile-1.5.0.zip
Description
1. Create simple JSF+CDI+EJB application consisting of one JSF page and one EJB component:
index.xhtml:
...
<h:body>
Current real date is: #
</h:body>
</html>
EJB: DateBean.java:
@Named
@RequestScoped
@Stateful
public class DateBean {
@PostConstruct
private void init()
@PreDestroy
private void die()
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.