Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Cache Configuration problem

 
Ranch Hand
Posts: 32
Eclipse IDE Spring Java
  • 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 Spring Java
  • 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 Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't there anybody who can help me on this ?
 
Ranch Hand
Posts: 344
Oracle Java Linux
  • 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.
 
Marshal
Posts: 25669
69
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
Oracle Java Linux
  • 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 Spring Java
  • 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".



 
    Bookmark Topic Watch Topic
  • New Topic