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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:34:24+00:00 2026-05-31T13:34:24+00:00

While integrating two subsystems, we were forced to use multiple SessionFactory instances, which lead

  • 0

While integrating two subsystems, we were forced to use multiple SessionFactory instances, which lead to trouble when interacting with our Hibernate second-level cache (Terracotta EhCache). Specifically:

 for(CacheManager cm : CacheManager.ALL_CACHE_MANAGERS){
            LOGGER.log(Level.DEBUG, "In cm " + cm.getName());
            for(String cn : cm.getCacheNames()){
                LOGGER.log(Level.DEBUG, "I have a cache called " + cn);
                LOGGER.log(Level.DEBUG, "it's status is " + ms.getCache(cn).getStatus());
            }
        }
  try{
     myCollection.size();
  }catch(IllegalStateException ise){
      LOGGER.log(Level.FATAL, ise);  //Triggered
  }        

The debug print-out shows STATUS_ALIVE for cache “Foo” but the call to size() throws an IllegalStateException:

java.lang.IllegalStateException: The Foo Cache is not alive.

Currently, both SessionFactories are configured to use SingletonEhCacheRegionFactory. If I switch the SessionFactories to use EhCacheRegionFactory (non-singleton), what are the ramifications for cache behavior (specifically in a Web App context)?

  • 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-31T13:34:25+00:00Added an answer on May 31, 2026 at 1:34 pm

    EhCache will ensure that all instances of SingletonEhCacheRegionFactory use the same actual CacheManager internally, no matter how many instances of SingletonEhCacheRegionFactory you create, making it a crude version of the Singleton design pattern.

    The plain EhCacheRegionFactory, on the other hand, will get a new CacheManager every time.

    If you have two Hibernate session factories in Spring, each using their own instance of SingletonEhCacheRegionFactory, then they’re actually going to end up sharing a lot of their cache state, which may account for your problem.

    This isn’t really a good match for Spring, where the singletons are supposed to be managed by the container. If you use EhCacheRegionFactory, then you’ll likely get more predictable results. I suggest giving it a go and see how you get on.

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

Sidebar

Related Questions

My company is currently using Sage MAS as their ERP system. While integrating our
Lets say I'm interacting with a system that has two incrementing counters which depend
I have two worksheets, one which is used to filter the other. Using VBA
I have a rather large solution, which contains two documentation projects based on Sandcastle
I have a class which is being operated on by two functions. One function
I have a problem while comparing the values in two vectors. Following is the
I'm looking for the best way to display all rows from two tables while
So I have two files, one that contains my text, and another which I
Duplicate Modifying A Collection While Iterating Through It Has anyone a nice pattern to
How do I access the index while iterating over a sequence with a 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.