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 8693855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:38:24+00:00 2026-06-13T00:38:24+00:00

I have an 2 application.One is application client,other one is EJB project. My client

  • 0

I have an 2 application.One is application client,other one is EJB project.
My client has references to server side.Container Managed Bean transaction is used in beans.I can not I inject entity manager to beans using following statement.

@PersistenceContext(unitName = "DBService")
private EntityManager em;

I have a message driven bean, 2 stateless bean and a singleton bean in server side.
I have local injection of 2 stateless bean from message driven bean.According to
message type of JMS message (it is come from server or client), message driven bean calls business methods of related statefull beans.Also each one of stateless beans inject singleton bean.

I am doing some changes on entities in singleton bean, updating some fields of entities, I am sending jms messages client or server. when messages are handled by 2 stateless beans, it calls business methods of singleton bean. For example I changed a field of entity.Then singleton bean send jms message to client, then client makes some work, then he send message back to server, server consumes this message in message driven bean, then it calls business method of related Stateless bean
, then stateless mean calls buısiness method of singleton bean.Then I am doing a query from database, But I can not see the latest state of changed entity.My changes are overwritten.
I thought that EntityManager of Singleton bean does not hold state of entities correctly if it is injected by multiple beans.I thought that same singleton bean instance must be get from connection pool. I have serious problems about this.

Do you think that my detection is correct? or I am doing something wrong?

Problem: I think that when a stateless bean calls a method of singleton bean new transaction begins, then second stateless beans calls a method of singleton bean, it also starts a transaction, but previous one is not committed, 2 transactions are not aware of changes which made by each other’s. But I do not know how to solve this. Using Bean managed transaction is a good solution for singleton beans?

  • 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-13T00:38:25+00:00Added an answer on June 13, 2026 at 12:38 am

    By default, beans annoted with @Singleton are container managed & uses locking mode LockType.WRITE, explicitly can apply @ConcurrencyManagement(CONTAINER).

    If any of the method is being called by a client, all the other requests will have to wait for the previous call to return. Here, you can apply lock to the entry method of the singleton bean & then can call other methods from within.

    You can also annotate at method level with @Lock(LockType.WRITE). Therefore, the sequence of the call will pertain the order in which they are called by the clients.


    Edit : The concurrent access to the singleton bean is serialized and the methods by default have REQUIRED transaction attribute.

    So the container invokes the bean’s method in the client’s transactional context. Therefore they will have individual transaction spanning from stateless bean to singleton bean.

    Stateless Bean A ----->                          ---> Read/Write 
    Stateless Bean B ----->  |C|B| Singleton --> |A| ---> Read/Write
    Stateless Bean C ----->                          ---> Read/Write
    

    As described above, request from bean B & C will be serialized/enqueued until A haven’t finished. So all the request will be processed in isolation without affecting others, but may probably lead to performance bottleneck.

    You can apply method level lock, @Lock(LockType.WRITE) for methods altering the shared data & @Lock(LockType.READ) for methods which access them.

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

Sidebar

Related Questions

I have some client-server application. And as one of its part, I need to
I am making simple one on server side & one on client side application
I have one application that I sold to multiple clients. Each client has his
The problem: we have one application that has a portion which is used by
I have 2 applications - one EAR containing EJB3.0 and other its Spring client.
I have a client-server application with 2 clients: I need to make the reading
I have an application which has two client and for both client i have
I have a Java application with server and Swing client. Now I need to
In one of my projects, I have an application that manages several clients (or
I have one application that prints messages from Test.exe in console .My java program

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.