This week's book giveaway is in the Android forum.
We're giving away four copies of Android Programming: The Big Nerd Ranch Guide and have Bill Phillips & Chris Stewart on-line!
See this thread for details.
Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question regarding @StatefulTimeout annotation on stateful session beans  RSS feed

 
Ajay Dhar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:



 
Ajay Dhar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!