• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Question regarding @StatefulTimeout annotation on stateful session beans

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.
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic