2014-12-17 6 views
7

Ich habe versucht, meine Spring- und Hibernate-Version zu aktualisieren. Ich benutzte Hibernate 3 und jetzt habe ich auf Hibernate 4.3.6 aktualisiert. Nach dem Upgrade bekomme ich ein seltsames Problem in der Echcache-Implementierung.Der Name [org.hibernate.cache.ehcache.EhCacheRegionFactory] kann nicht als Strategie aufgelöst werden [org.hibernate.cache.spi.RegionFactory]

Wie ich Upgrade 4 in den Ruhezustand, ich habe hinzugefügt einen Eintrag als:

<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory </prop> 

Und jetzt bin ich immer die Ausnahme als:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/persistence.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1127) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1051) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:949) 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:603) 
    ... 124 more 
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory] 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:261) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206) 
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:295) 
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2444) 
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2440) 
    at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSettings(LocalSessionFactoryBuilder.java:343) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1930) 
    at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372) 
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454) 
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562) 
    ... 134 more 
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory] 
    at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:101) 
    at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:46) 
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:105) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251) 
    ... 147 more 
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory] 
    at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:128) 
    at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:87) 
    ... 150 more 

Die Bibliotheken sind:

antlr.jar 
aopalliance.jar 
asm-3.3.jar 
aspectj-1.7.0.jar 
aspectjweaver-1.5.4.jar 
backport-util-concurrent-1.1_01.jar 
c3p0.jar 
cglib-2.2.2.jar 
commons-beanutils-1.7.0.jar 
commons-codec-1.6.jar 
commons-collections-3.2.1.jar 
commons-dbcp-1.3.jar 
commons-lang3-3.1.jar 
commons-logging-1.1.1.jar 
commons-pool-1.6.jar 
dom4j-1.6.1.jar 
ehcache-1.5.0.jar 
gson-2.3.1.jar 
hibernate-commons-annotations-4.0.5.Final.jar 
hibernate-core-4.3.6.Final.jar 
hibernate-core-4.3.7.Final.jar 
hibernate-ehcache-4.3.7.Final.jar 
hibernate-entitymanager-4.3.7.Final.jar 
hibernate-jpa-2.1-api-1.0.0.Final.jar 
hibernate-validator-5.1.3.Final.jar 
jakarta-oro.jar 
jboss-logging-3.2.0.Final.jar 
jdom.jar 
jsr107cache-1.0.jar 
log4j-1.2.17.jar 
ojdbc14.jar 
poi-3.6-20091214.jar 
samlutility.jar 
sitemesh-2.4.2.jar 
slf4j-api-1.6.1.jar 
slf4j-api-1.7.7.jar 
slf4j-log4j12-1.6.1.jar 
spring-aop-4.1.3.RELEASE.jar 
spring-beans-4.1.3.RELEASE.jar 
spring-context-4.1.3.RELEASE.jar 
spring-context-support-4.1.3.RELEASE.jar 
spring-core-4.1.3.RELEASE.jar 
spring-expression-4.1.3.RELEASE.jar 
spring-jdbc-4.1.3.RELEASE.jar 
spring-jms-4.1.3.RELEASE.jar 
spring-orm-4.1.3.RELEASE.jar 
spring-security-config-3.2.5.RELEASE.jar 
spring-security-core-3.2.5.RELEASE.jar 
spring-security-taglibs-3.2.5.RELEASE.jar 
spring-security-web-3.2.5.RELEASE.jar 
spring-tx-4.1.3.RELEASE.jar 
spring-web-4.1.3.RELEASE.jar 
spring-webmvc-4.1.3.RELEASE.jar 
validation-api-1.1.0.Final.jar 
xmlsec-1.4.5.jar 

Ich versuchte alle möglichen Möglichkeiten, aber das behebt dieses Problem nicht.

+0

Sind Sie Hibernate Frühjahr mit der Konfiguration? Wenn ja, vergewissern Sie sich, dass die Versionen kompatibel sind, zB Spring vs Hibernate Versionen – Zeus

Antwort

1

Verwendung folgende Abhängigkeit:

 <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-ehcache</artifactId> 
     <version>4.3.7.Final</version> 
    </dependency> 
2

in den Ruhe 4, wenn Sie Ehcache verwenden möchten, müssen Sie eine bestimmte Abhängigkeit hinzufügen: Hibernate-ehcache

Aber es bettet Ehcache 2.4.3 So Sie sollten die eingebettete Ehcache-Abhängigkeit ausschließen.

<dependency> 
<groupId>org.hibernate</groupId> 
<artifactId>hibernate-ehcache</artifactId> 
<version>4.1.9.Final</version> 
<exclusions> 
    <exclusion> 
     <groupId>net.sf.ehcache</groupId> 
     <artifactId>ehcache-core</artifactId> 
    </exclusion> 
</exclusions> 
</dependency> 

für Hibernate-ehcache ab Version 5.1.0.Final die Ehcache 2.10.1 sieht gleich Ausschluss verwendet etwas andere (ehcache statt ehcache-core)

<dependency> 
<groupId>org.hibernate</groupId> 
<artifactId>hibernate-ehcache</artifactId> 
<version>5.1.0.Final</version> 
<exclusions> 
    <exclusion> 
     <groupId>net.sf.ehcache</groupId> 
     <artifactId>ehcache</artifactId> 
    </exclusion> 
</exclusions> 
</dependency> 

und dann je nach Version ehcache, müssen Sie ehcache oder ehcache-Core

bis zu 2.6.x hinzuzufügen:

<dependency> 
<groupId>net.sf.ehcache</groupId> 
<artifactId>ehcache-core</artifactId> 
<version>2.5.7</version> 
</dependency> 

für 2.7 und höher

<dependency> 
<groupId>net.sf.ehcache</groupId> 
<artifactId>ehcache</artifactId> 
<version>2.7.0 or above</version> 
</dependency> 

und für 3.0 und höher

<dependency> 
    <groupId>org.ehcache</groupId> 
    <artifactId>ehcache</artifactId> 
    <version>3.0.0</version> 
</dependency> 
+0

Die Verwendung von Ehcache 3.0 und höher mit der aktuell verfügbaren Hibernate-ehcache-Version (5.2.10.Final) ist wahrscheinlich nicht möglich (es werden Fehler auftreten). Sie können nur Ehcache 2.x.x damit verwenden. Aber es ist für jetzt. In Zukunft wird sich das wahrscheinlich mit der neuen Hibernate-ehcache-Version ändern. – luke

Verwandte Themen