It's not a secret anymore!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question regarding @StatefulTimeout annotation on stateful session beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question regarding @StatefulTimeout annotation on stateful session beans" Watch "Question regarding @StatefulTimeout annotation on stateful session beans" New topic
Author

Question regarding @StatefulTimeout annotation on stateful session beans

Ajay Dhar
Ranch Hand

Joined: Jan 26, 2011
Posts: 30
I just started going through Ivan's notes. I'm on chapter 2, Create a Stateful Session Bean. I coded the first example from this chapter in Eclipse using Glassfish.

The code example works for the most part, however I do not see the @StatefulTimeout(value=10, unit=TimeUnit.SECONDS) taking effect. Whenever I call the EJB from the servlet client multiple times within 10 seconds it displays the greeting properly, as expected. However, if I wait more than 10 seconds between requests, the session bean should timeout and I should get a NoSuchEJBException upon a subsequent request. However, I am not getting any error, a greeting is be sent back to the client. I even tried reducing the timeout to 1 second but to no avail. Also, I added @PrePassivate and @PostActivate methods to see if the @StatefulTimeout was causing the bean to passivate, but those callback methods weren't being called.

I have provided the code snippets of the stateful session bean and servlet client below. Does someone know what is going on? The @StatefulTimeout annotation doesn't seem to be taking effect. I'm a little confused.

Any help is appreciated.

Stateful Session Bean:


Servlet client:




OCPJP 6, OCEEJBD 6, GIAC Secure Software Programmer-Java (GSSP-Java)
Ajay Dhar
Ranch Hand

Joined: Jan 26, 2011
Posts: 30
Jeez... 5 minutes after making this post I realized that my session bean is annotated as @Stateless instead of @Stateful... Lol. I'll try it again as a Stateful bean. I'll post again if I run into any issues.
 
 
subject: Question regarding @StatefulTimeout annotation on stateful session beans
 
Similar Threads
Method names starting with 'ejb'
EJB Spec violationg for session bean rules.
EJB3.0 CallBack methods - simple doubt
Method names starting with 'ejb'
Missed PreDestroy callback calls