Hello,
I am in the process of migrating our app from Hibernate 3.2.7 to 4.1.4 (on JBoss 5.0) and am always getting this warning when accessing a cache region for the first time:
Code:
17:31:53,474 WARN [AbstractEhcacheRegionFactory] HHH020003: Could not find a specific ehcache configuration for cache named [com.accovia.jawa.dom.system.Flag]; using defaults.
17:31:53,660 WARN [EhcacheAccessStrategyFactoryImpl] HHH020007: read-only cache configured for mutable entity [com.accovia.jawa.dom.system.Flag]
17:31:54,809 INFO [UpdateTimestampsCache] HHH000250: Starting update timestamps cache at region: org.hibernate.cache.spi.UpdateTimestampsCache
17:31:55,489 WARN [AbstractEhcacheRegionFactory] HHH020003: Could not find a specific ehcache configuration for cache named [org.hibernate.cache.spi.UpdateTimestampsCache]; using defaults.
17:31:55,499 INFO [StandardQueryCache] HHH000248: Starting query cache at region: org.hibernate.cache.internal.StandardQueryCache
17:31:56,269 WARN [AbstractEhcacheRegionFactory] HHH020003: Could not find a specific ehcache configuration for cache named [org.hibernate.cache.internal.StandardQueryCache]; using defaults.
I have the following in my hibernate.properties defining the ehcache defs ...
Code:
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
net.sf.ehcache.configurationResourceName=/ehcache.xml
And my ehcache.xml file is located at the root of my ear.
Here is a sample
Code:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd">
<diskStore path="java.io.tmpdir"/>
<!--
Mandatory Default Cache configuration. These settings will be applied to caches
created programatically using CacheManager.add(String cacheName)
-->
<defaultCache
maxElementsInMemory="400000"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="1800"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
<cache name="com.accovia.jawa.dom.system.Flag"
maxElementsInMemory="50"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="1800"
overflowToDisk="false"
/>
</ehcache>
We have code to override/add props when we build the session factory like the following:
Code:
// Load the file hibernate.properties if found in the classpath
this.configuration = new Configuration();
// Load the properties file related to the ds reference
String hibernatePropertyFilename = getHibernatePropertyFilename(aHibernateDataSourceReference);
URL url = Thread.currentThread().getContextClassLoader().getResource(hibernatePropertyFilename);
if (url != null) {
InputStream in = url.openStream();
Properties props = new Properties();
props.load(in);
HibernatePropertiesHelper.loadOverrideProperties(props, new StringBuffer().append(EXTERNAL_HIBERNATE_PROPERTY_IDENTIFIER).append(aHibernateDataSourceReference).toString());
this.configuration.addProperties(props);
//this.configuration.setProperties(props);
in.close();
if (LOG.isDebugEnabled()) {
LOG.debug(hibernatePropertyFilename + " loaded...");
}
}
// Load the hibernate mapping config file(s)
String configFile = ConfigurationManagerFactory.CONFIGURATION_MANAGER_INSTANCE.getPropertyManager().getProperty(HIBERNATE_SERVICE, CONFIG_FILE, null);
if (StringUtils.isNotBlank(configFile)) {
this.configuration.configure(configFile);
this.sessionFactory = this.configuration.buildSessionFactory();
if (LOG.isDebugEnabled()) {
LOG.debug("SessionFactory built from " + HIBERNATE_SERVICE + CONFIG_FILE);
}
}
// Load the default hibernate mapping config file hibernate.cfg.xml
else {
Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(DEFAULT_HIBERNATE_MAPPING_FILE);
for (; urls.hasMoreElements();) {
URL cfgUrl = urls.nextElement();
if (cfgUrl != null) {
this.configuration.addURL(cfgUrl);
//this.configuration.configure(cfgUrl);
}
}
this.configuration.configure();
this.sessionFactory = this.configuration.buildSessionFactory();
if (LOG.isDebugEnabled()) {
LOG.debug("SessionFactory built from " + DEFAULT_HIBERNATE_MAPPING_FILE);
}
}
Can anyone give me pointers as to why I am seing this warning which seem to indicate that my ehcache file is not used ?!?
Thank you