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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:13:16+00:00 2026-05-11T16:13:16+00:00

I have a Web application using spring and hibernate and struts (it runs on

  • 0

I have a Web application using spring and hibernate and struts (it runs on Tomcat)

The call sequence is something like this…

Struts action calls spring service bean which in turn calls Spring DAO bean. The DAO implementation is a Hibernate implementation.

The question is
Would all my spring beans be running in the same thread ?
Can I store something in the ThreadLocal and get it in another bean?

I am quite sure this would not work in Stateless Session Bean.
The EJB container can (or will) spawn a new thread for every call to the session bean

Will the spring container do the same? i.e. run all beans in the same thread ?

When I tried a JUnit test – I got the same id via Thread.currentThread().getId() in the Test Case and the two beans- which leads me to believe there was only one thread in action

Or is the behavior unpredictable?
Or will it change when running on Tomcat server ?

Clarification
I do not wish to exchange data between two threads. I want to put data in the ThreadLocal and be able to retrieve it from all beans in the call stack. This will work only if all beans are in the same thread

  • 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-11T16:13:16+00:00Added an answer on May 11, 2026 at 4:13 pm

    Spring doesn’t spawn the threads. Tomcat does. Spring is just creating and wiring up the objects for you.

    Each request from the browser is processed in one request. It is Tomcat that handles the request. It is Tomcat that creates the thread to process the request.

    Assuming you have just created a singleton bean in Spring called “X”. Then the same instance of X is used by all requests.

    The Spring beans don’t live in a thread. They are just allocated on the heap.

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

Sidebar

Ask A Question

Stats

  • Questions 204k
  • Answers 204k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer We used to write our integration tests (smoke tests if… May 12, 2026 at 8:42 pm
  • Editorial Team
    Editorial Team added an answer Are any of the parameters passed to the callback function… May 12, 2026 at 8:42 pm
  • Editorial Team
    Editorial Team added an answer Leaving a connection open for a while is fine, as… May 12, 2026 at 8:42 pm

Related Questions

Hey I am developing an desktop application using Spring and Hibernate, and I have
So I've got a simple web application using Spring MVC + Hibernate and am
Is using the 'synchronized' keyword on methods in a Java DAO going to cause
An application that has been working well for months has stopped picking up the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.