陈建华的博客
专注web开发
Unable to create requested service [org.hibernate.engine.spi.CacheImple
2014-07-22 09:51:46   阅读10472次

在使用Hibernate4做二级缓存的测试(HashtableCacheProvider)时,会报如下异常:
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.spi.CacheImplementor]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:186)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
    at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:262)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1746)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1784)
    at action.QueryCache.main(QueryCache.java:19)
Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given, please either disable second level cache or set correct region factory class name to property hibernate.cache.region.factory_class (and make sure the second level cache provider, hibernate-infinispan, for example, is available in the classpath).
    at org.hibernate.cache.internal.NoCachingRegionFactory.buildTimestampsRegion(NoCachingRegionFactory.java:87)
    at org.hibernate.cache.spi.UpdateTimestampsCache.(UpdateTimestampsCache.java:63)
    at org.hibernate.internal.CacheImpl.(CacheImpl.java:72)
    at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:40)
    at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:35)
    at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:91)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176)
    ... 6 

1.

1.jpg


2.在org.hibernate.cache包下面缺少很多class文件,如HashtableCacheProvider.class等,你可以将hibernate3中org.hibernate.cache下面的文件拷贝到hibernate4的核心jar包下,或者使用Hibernate3的核心jar包。





-----------------------------------------------------
转载请注明来源此处
原地址:#

-----网友评论----
1楼:太空守望者 发表于 2014-07-24 16:02:35
这个挺好的。
2楼:太空守望者 发表于 2014-07-24 16:03:23
说的说的说的
-----发表评论----
微网聚博客乐园 ©2014 blog.mn886.net 鲁ICP备14012923号   网站导航