Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6148649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:19:03+00:00 2026-05-23T19:19:03+00:00

Suppose I let my customer reserve seats on a plane using Stateful Session Bean.

  • 0

Suppose I let my customer reserve seats on a plane using Stateful Session Bean. If the client explicitly calls my Remove method, all of his reservations will be cancelled and the bean is removed afterward.

However, in case the client is idle for some time and the Bean get passivated, if the Bean times out while being passivated, it would be deleted without calling any of my functions. Hence, I’d be very grateful if someone could show me how I can make sure that the reservations would be cancelled if the bean get deleted. If I use the @PreDestroy annotation, will it solve this problem?

Best regards,
James Tran

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:19:03+00:00Added an answer on May 23, 2026 at 7:19 pm

    It is quite possible for the @PreDestroy method to not be invoked. The EJB 3.1 specification, explicitly states this:

    4.6.3 Missed PreDestroy Calls

    The Bean Provider cannot assume that the container will always invoke
    the PreDestroy lifecycle callback interceptor method(s) (or ejbRemove
    method) for a session bean instance. The following scenarios result in
    the PreDestroy lifecycle callback interceptor method(s) not being
    called for an instance:

    • A crash of the EJB container.

    • A system exception thrown from the instance’s method to the container.

    • A timeout of client inactivity while the instance is in the passive state. The timeout is specified by the Deployer in an EJB container implementation-specific way.

    The specification also details how resources may be removed if the @PreDestroy method is not invoked in such scenarios:

    For example, if a shopping cart component is implemented as a session
    bean, and the session bean stores the shopping cart content in a
    database, the application should provide a program that runs
    periodically and removes “abandoned” shopping carts from the database.

    In your case, it would depend on how you are storing the state of your reservations. If they are persisted in the database, then I would suggest employing the same approach as mandated in the specification. You could use the EJB Timer service, to perform this activity periodically, or use a scheduler like Quartz. Note, that it is imperative to distinguish between the contents of passivated session bean instances that no longer exist, and those that will be made ready once again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I let the user to write a condition using Javascript, the user can
Let's suppose I'm using the Northwind database and I would like to run a
Let's suppose I define a domain class named Client in several datasources and create
Let's suppose I have some method that returns a IEnumerable<int> object. This methods make
Let's suppose I have the following structure in my project (I'm using iBatis as
For example I have a wpf window bound to an customer Entity (let suppose
Suppose you have to develop a software to access customer database, let's say for
Let's suppose we have a base class which has a virtual method: class BaseClass
Let's assume, we create a stored procedure that is supposed to retrieve customer details
Let's suppose I have an applet running within a page in a browser. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.