我想實現我們的產品二級緩存與Hibernate版本3hibernate ehcache配置問題:從null配置錯誤。最初的原因是空
然而,當我嘗試訪問我的申請,我得到以下錯誤:
[ HibernateSessionFactory ] :
java.lang.NullPointerException at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:102) [wrapped] net.sf.ehcache.CacheException: Error configuring from null. Initial cause was null
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:105)
at net.sf.ehcache.hibernate.HibernateUtil.loadAndCorrectConfiguration(HibernateUtil.java:51)
at net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory.start(SingletonEhCacheRegionFactory.java:76)
[wrapped] org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Error configuring from null. Initial cause was null
at net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory.start(SingletonEhCacheRegionFactory.java:82)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:238)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
休眠。 cfg.xml文件:
<hibernate-configuration>
<session-factory>
<property name="net.sf.ehcache.configurationResourceName">ehcache.xml</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_structured_entries">true</property>
<property name="hibernate.cache.generate_statistics">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory</property>
...
...
</session-factory>
</hibernate-configuration>
ehcache.xml中
<ehcache>
<defaultCache maxElementsInMemory="100" eternal="false"
timeToIdleSeconds="500" timeToLiveSeconds="1000" />
<cache name="Audit" maxElementsInMemory="100"
eternal="false" timeToIdleSeconds="500" timeToLiveSeconds="1000" />
</ehcache>
我使用下面的罐來實現緩存:
- ehcache的核心 - 2.6.10.jar
- 休眠-3.6.6.jar
- 休眠 - 驗證 - 4.2.0。 Final.jar
請指導我,哪裏出問題了。爲什麼它顯示文件爲空。兩個配置文件都在同一個文件夾中。
我也試過這個選項,但它沒有奏效。然而,經過3天的浪費,我找到了解決方案。請檢查我的答案是否一樣。 –
是的......如果你的文件在配置/然後指定它似乎要走的路......你應該告訴我們該文件在你的問題的位置。它看起來像是在類路徑的根部。 – Henri