Hi there,
I'm trying to setup a 2nd level cache using JBossCache. I have a web application running under JBoss 4.0.3 and another application running on a different machine. Both applications have the potential to update the database. I am using the org.hibernate.cache.JndiBoundTreeCacheProvider
tree cache in my hibernate.cfg.xml file, and am defining the mbean in the jboss-service.xml file.
Upon startup, JBoss is correctly starting the TreeCache MBean, however hibernate is failing to find it when creating the Session due to a JNDI namespace issue. I noticed that the org.hibernate.cfg.Environment class has a CACHE_NAMESPACE property on it, and thinking this would work in a similar way to the TRANSACTION_MANAGER_STRATEGY property, I tried to set:
<property name="cache.jndi">jboss.cache:service=TreeCache</property>
in my hibernate.cfg.xml file. However, this complained that the hibernate.cfg file was now invalid, so that is obviously not the way to do it.
Without that property set I get the following error occur when I start up JBoss:
Quote:
org.hibernate.cache.CacheException: No JNDI namespace specified for cache
at org.hibernate.cache.AbstractJndiBoundCacheProvider.start(AbstractJndiBoundCacheProvider.java:44)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:173)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
My hibernate.cfg.xml file can be found
here
My jboss-service.xml file can be found
here
A full stack trace of the error can be found
here
I have also tried using the org.jboss.hibernate.cache.DeployedTreeCacheProvider in the hibernate.cfg.xml file instead of the JndiBoundTreeCacheProvider, but doing so causes the following
ClassCastException
Can someone please tell me how I get my cache working either by letting me know where I specify the JNDI namespace when using the JndiBoundTreeCacheProvider, or tell me what I am doing wrong when using the DeployedTreeCacheProvider.
Many thanks in advance,
Ben
Hibernate version:
Hibernate-Version: 3.1.3
Name and version of the database you are using:
version=Oracle 10g
name=MM