I'm trying to get caching working in Hibernate Core, but I'm getting a NullPointerException when I access a cached object the second time (i.e. when Hibernate actually resorts to a cache). Here is the full stack trace:
Code:
SEVERE: Servlet.service() for servlet default threw exception
java.lang.NullPointerException
at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.nextTimestamp(RegionFactoryCacheProviderBridge.java:85)
at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:526)
at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:535)
at org.apache.jsp.cms.index_jsp._jspService(index_jsp.java:61)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:139)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
Note: I'm using Struts2 so there's more to this stack dump, but I don't think the rest is relevant.
At any rate, in my hibernate configuration I have:
Code:
<property name="hibernate.cache.provider_class">
net.sf.ehcache.hibernate.EhCacheProvider
</property>
And here is my EhCache configuration:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
/>
<cache name="DataObj"
maxElementsInMemory='2000'
eternal='true'
timeToIdleSeconds='0'
timeToLiveSeconds='0'
overflowToDisk='false'
/>
</ehcache>
I looked at RegionFactoryCacheProviderBridge, and it appears that cacheProvider has not been initialized, which is weird. Any ideas?
Thanks.
-- delsvr