Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cache Configuration problem

 
mozammil muzza
Ranch Hand
Posts: 32
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
mozammil muzza
Ranch Hand
Posts: 32
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

Expecting some reply for this.
 
mozammil muzza
Ranch Hand
Posts: 32
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't there anybody who can help me on this ?
 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21572
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 344
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe the <cache> tag is in the wrong place. Should it go inside <ehcache> tags?
 
mozammil muzza
Ranch Hand
Posts: 32
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic