| Author |
Cache Configuration problem
|
mozammil muzza
Greenhorn
Joined: Dec 22, 2011
Posts: 29
|
|
hi Guys,
I am experimenting with the Hibernate Caching and trying to get ideas on cache management specially second level cache.
Here i am using "EhCache' for my small apps as it is the default for hibernate.
but i am getting exception :
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.muzza.java.test.HibernateTestClient.loadInTwoSessions(HibernateTestClient.java:122)
at org.muzza.java.test.HibernateTestClient.main(HibernateTestClient.java:25)
Caused by: net.sf.ehcache.CacheException: Error configuring from file:/D:/Workspace/Testworkspace/CoreJavaProject/config/ehcache.xml. Initial cause was Error configuring from input stream. Initial cause was null:11: Element <cache> does not allow attribute "name".
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:95)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:131)
at net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:241)
at net.sf.ehcache.CacheManager.init(CacheManager.java:190)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:183)
at org.hibernate.cache.EhCacheProvider.start(EhCacheProvider.java:124)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:183)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
at org.muzza.java.util.HibernateUtil.<clinit>(HibernateUtil.java:18)
... 2 more
my ehcache.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<cache name="org.muzza.java.pojo.Employee"
maxElementsInMemory="300"
eternal="true"
overflowToDisk="false"
timeToIdleSeconds="12000"
timeToLiveSeconds="12000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
Please tell me the reason why this is saying this for the name attribute ??
Thanks
|
Khuda Haafiz Muzza 4 Java
|
 |
mozammil muzza
Greenhorn
Joined: Dec 22, 2011
Posts: 29
|
|
Hi friends,
Expecting some reply for this.
|
 |
mozammil muzza
Greenhorn
Joined: Dec 22, 2011
Posts: 29
|
|
|
Isn't there anybody who can help me on this ?
|
 |
Koen Aerts
Ranch Hand
Joined: Feb 07, 2012
Posts: 344
|
|
|
Well, the message is telling you that the "name" attribute in the <cache> tag is not allowed. So remove the name="org.muzza.java.pojo.Employee" part in your ehcache.xml file.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
|
Still, that's odd, because the XSD for the EHCache XML file says that not only is "name" a permitted attribute on the <cache> element, it's a required attribute.
|
 |
Koen Aerts
Ranch Hand
Joined: Feb 07, 2012
Posts: 344
|
|
|
Maybe the <cache> tag is in the wrong place. Should it go inside <ehcache> tags?
|
 |
mozammil muzza
Greenhorn
Joined: Dec 22, 2011
Posts: 29
|
|
Hi ALL,
Correct Koen, <cache> tag must be inside <ehcache> tag with which we cab define many cache for different bean and also sometime there is need to define defaultcache, otherwise gives exception something like "DefaultCache is not defined or set".
|
 |
 |
|
|
subject: Cache Configuration problem
|
|
|