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

  • Home
  • SEARCH
  • 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 8982723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:39:06+00:00 2026-06-15T20:39:06+00:00

There is an technology stack: Java EE (WebSpere), JPA, EJB3, JMS (MDB), JSF. Architecture:

  • 0

There is an technology stack: Java EE (WebSpere), JPA, EJB3, JMS (MDB), JSF.

Architecture: JMS messages arrive (via MDB) and are registered as persisted entities – (using EntityManager). There is a Singleton class with infinite loop which is responsible for processing of those entities. The Singleton is notified about created entities by MDB. Initially entities are stored in queue inside the Singleton. Created entity can be processed up to several minutes. No more than certain amount of entities can be processed simultaneously (several parallel processes in Singleton). The Singleton is not an EJB, but there are EJB services used by it. There is a class which represents Execution Context for given entity (simple DTO). The Execution Context holds dependencies on needed EJBs and is created on MDB interaction step and passed to the Singleton service along with notification a new message (basically MDB has annotated injections of those EJBs and EM, and creates new Execution Context passing those injected instances).

The problem is: processing of an entity is started but EntityManager at some point of time (after a few seconds) begins returning nulls for search requests, and it should not, as just a second ago the entity was updated.

It looks like the architecture is not good. I suspect that the EM’s behavior is a sign that persistence context has gone after some time after interaction between MDB and the Singleton has done.
Singleton has life time much longer than life time of any managed bean in system. So, injection of EJB instances (and EM instance) to such component seems not to be a solution at all (passing references to injected EJB instances from MDB to the Singleton probably is a worst decision).

Probably EJB, as well as EM should be looked up by the Singleton using JNDI each time they are needed?
In this case, should I lockup the EJBs for each call?

Which way would you design the system: if MDB only registered message (as entities). And processing of entities may start latter. And you have to use some EJB services (local interface). And there is Entity Manager as well.

  • 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-06-15T20:39:07+00:00Added an answer on June 15, 2026 at 8:39 pm

    If the entity manager that the Singleton is using is transaction scoped, then the lifetime of the Singleton doesn’t matter. In a way, stateless session beans also have an infinite lifetime once created (their scope is essentially ‘none’, but their instances are pooled and kept being re-used).

    Every time the method in the singleton services a request, a new transaction is started and a new persistence context is piggy-backed to that, even though the entity manager instance seems to be the same throughout those requests. This is normal behavior and should not ‘suddenly’ return nulls.

    It might be worth checking if your singleton is using appropriate locks. If the entity manager is accessed concurrently then this may be the cause of undefined behavior.

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

Sidebar

Related Questions

Is there any possibility using the drag&drop technology for dragging desktop images onto a
I have trouble choosing the right audio playback technology. There's a ton of technologies
i would like to know how the update messages in this stack overflow site
My Web application makes use of Ext JS & Java web technology. Due to
We've recently upgraded our services technology stack. We opted for the WSIT implementation of
What does the technology stack for mobile applications (native and HTML5) look like for
We are a Microsoft shop, have a reasonably mature technology stack and have very
Until now I was mainly using Struts 2 , Spring , JQuery technology stack
I'm trying to figure out how OCaml is represented in enterprise technology stack. For
Are there any what in the Java community would be called application servers for

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.