Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

In Spring, FOUR instances of EVERY singleton being created!!! Help!

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using spring with tomcat, and the app seems to work fine, but now I'm doing some caching stuff, and I'm running into problems. It appears that I'm getting four instances of every "singleton" created in the app. If I put a log message in like log.error("Object address: " + this); into the code, then it spits out four different object addresses, four different times. If I put a breakpoint into my debugger inside a "singleton" constructor, it calls it four times (multithreaded)! What the heck is going on? Why is my spring container duplicating everything four times???

Anybody?

Thanks in advance,

Jerry
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the multithreaded code and sections where you are retrieving the spring beans or the bean definition?

------
Regards
Ravindra
 
Jerry Destremps
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out. It was my virtual hosting settings. I was using webapps as the appBase in the host tag. I needed to add the directory of the app onto that. like webapps/ROOT and webapps/customerportal. What was happening (if you looked in the work directory) is that it was creating ALL the apps for every virtual host mentioned in the server.xml file. It's all fixed now and I'm down to one singleton per app as life should be....
 
What's that smell? I think this tiny ad may have stepped in something.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!