Невозможно настроить ehcache с Hibernate 5.3.5, Ehcache 3.5.2, jdk 8, wildfly 8 - PullRequest
0 голосов
/ 31 августа 2018

Я использую Hibernate 5.3.5, с ehcache 3.5.2, в моем hibernate.cfg.xml есть следующие записи

<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property> 
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.jcache.JCacheRegionFactory</property>
<property name="hibernate.javax.cache.provider">org.ehcache.jsr107.EhcacheCachingProvider</property>

Я добавил следующие баночки в мой путь к классу

  • EHCache-3.5.2
  • hibernate-core-5.3.5.Final
  • hibernate-jcache-5.3.5.Final
  • байты-дружелюбный 1.8.17
  • кэш-апи-1.1.0
  • SLF4J-апи-1.7.7

при запуске wildfly я получаю следующее исключение

            17:56:16,516 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./App: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./App: Failed to start service
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_92]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_92]
                at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_92]
            Caused by: java.lang.ExceptionInInitializerError
                at com.dam.HibernateUtils.<clinit>(HibernateUtils.java:92)
                at com.dam.listeners.SettingsListener.contextInitialized(SettingsListener.java:71)
                at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
                at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:190)
                at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
                at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
                ... 3 more
            Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.CacheImplementor]
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275)
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214)
                at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:109)
                at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:239)
                at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
                at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
                at com.dam.HibernateUtils.<clinit>(HibernateUtils.java:85)
                ... 10 more
            Caused by: org.ehcache.jsr107.MultiCacheException: [Exception 0] sun/misc/Unsafe
                at org.ehcache.jsr107.Eh107CacheManager.createCache(Eh107CacheManager.java:202)
                at org.hibernate.cache.jcache.internal.JCacheRegionFactory.createCache(JCacheRegionFactory.java:111)
                at org.hibernate.cache.jcache.internal.JCacheRegionFactory.getOrCreateCache(JCacheRegionFactory.java:98)
                at org.hibernate.cache.jcache.internal.JCacheRegionFactory.createTimestampsRegionStorageAccess(JCacheRegionFactory.java:155)
                at org.hibernate.cache.spi.support.RegionFactoryTemplate.buildTimestampsRegion(RegionFactoryTemplate.java:70)
                at org.hibernate.cache.internal.EnabledCaching.<init>(EnabledCaching.java:80)
                at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:33)
                at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:24)
                at org.hibernate.service.spi.SessionFactoryServiceInitiator.initiateService(SessionFactoryServiceInitiator.java:30)
                at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:68)
                at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
                ... 18 more
...