I've worked around this, but I thought I would post it in case it's not expected or in case someone else runs into it:
If I don't wrap my buildSessionFactory() call in a synchronized block, there would be cases where the session factory singleton was getting created twice.
Seems like no killer problem, but when it happened I would get a slew of errors from CacheFactory:
Code:
ERROR CacheFactory:89 - Cache of type [edu.academyart.model.Post] already exists.
And then I would get NullPonterException from SwarmCache.get when I tried to load one of my objects:
Code:
java.lang.NullPointerException
at net.sf.hibernate.cache.SwarmCache.get(SwarmCache.java:27)
at net.sf.hibernate.cache.NonstrictReadWriteCache.get(NonstrictReadWriteCache.java:35)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2033)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1916)
at net.sf.hibernate.impl.SessionImpl.load
I've fixed this problem in my code but I wanted to toss it out there in case it was also revealing a problem in the SwarmCache implementation of the object cache.
-mp