This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question regarding @StatefulTimeout annotation on stateful session beans
 
Similar Threads
Missed PreDestroy callback calls
EJB Spec violationg for session bean rules.
Method names starting with 'ejb'
Method names starting with 'ejb'
EJB3.0 CallBack methods - simple doubt