0 Replies Latest reply on Dec 25, 2013 2:26 AM by hantsy bai

    Issues I encountered when use infinispan as JPA 2L cache

    hantsy bai Master

      I tried to use infinispan as JPA/Hiberante 2L cache in Spring sample codes(none JBoss runtime), I followed the official guide

      http://infinispan.org/docs/5.3.x/user_guide/user_guide.html#_using_infinispan_as_jpa_hibernate_second_level_cache_provider

       

      But it does not work as expected.

       

      My env is Spring 3.2.6, Hibernate 4.2.8, Infinispan 5.3.

       

      Configuration of Hiberante 2L cache.

       

      hibernate.cache.use_second_level_cache=true
      hibernate.cache.use_query_cache=true
      hibernate.cache.region.factory_class = org.hibernate.cache.infinispan.InfinispanRegionFactory

       

       

      And enable JPA 2L cache in persistence.xml.

       

      <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
      
      
      

       

      And add @Cachable annoation in entity class.

       

      @Entity
      @Cacheable(true)
      //@Cache(usage=CacheConcurrencyStrategy.READ_ONLY, region="conf_region")
      public class Conference {
      
      
      

       

      But finally, I got an exception:

      Caused by: org.infinispan.CacheException: This is transactional cache but no transaction manager could be found. Configure the transaction manager lookup properly.
          at org.infinispan.factories.TransactionManagerFactory.construct(TransactionManagerFactory.java:71)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:292)
          at org.infinispan.factories.ComponentRegistry.getOrCreateComponent(ComponentRegistry.java:165)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:247)
          at org.infinispan.factories.AbstractComponentRegistry.access$000(AbstractComponentRegistry.java:87)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:817)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponentInternal(AbstractComponentRegistry.java:221)
          at org.infinispan.factories.ComponentRegistry.registerComponentInternal(ComponentRegistry.java:192)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:176)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:297)
          at org.infinispan.factories.ComponentRegistry.getOrCreateComponent(ComponentRegistry.java:165)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:247)
          at org.infinispan.factories.AbstractComponentRegistry.access$000(AbstractComponentRegistry.java:87)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:817)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponentInternal(AbstractComponentRegistry.java:221)
          at org.infinispan.factories.ComponentRegistry.registerComponentInternal(ComponentRegistry.java:192)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:176)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:297)
          at org.infinispan.factories.ComponentRegistry.getOrCreateComponent(ComponentRegistry.java:165)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:247)
          at org.infinispan.factories.AbstractComponentRegistry.access$000(AbstractComponentRegistry.java:87)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:817)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponentInternal(AbstractComponentRegistry.java:221)
          at org.infinispan.factories.ComponentRegistry.registerComponentInternal(ComponentRegistry.java:192)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:176)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:297)
          at org.infinispan.factories.ComponentRegistry.getOrCreateComponent(ComponentRegistry.java:165)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:247)
          at org.infinispan.factories.AbstractComponentRegistry.access$000(AbstractComponentRegistry.java:87)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:817)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponentInternal(AbstractComponentRegistry.java:221)
          at org.infinispan.factories.ComponentRegistry.registerComponentInternal(ComponentRegistry.java:192)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:176)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:297)
          at org.infinispan.factories.ComponentRegistry.getOrCreateComponent(ComponentRegistry.java:165)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:247)
          at org.infinispan.factories.AbstractComponentRegistry.access$000(AbstractComponentRegistry.java:87)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:817)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponentInternal(AbstractComponentRegistry.java:221)
          at org.infinispan.factories.ComponentRegistry.registerComponentInternal(ComponentRegistry.java:192)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:176)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:297)
          at org.infinispan.factories.ComponentRegistry.getOrCreateComponent(ComponentRegistry.java:165)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:247)
          at org.infinispan.factories.AbstractComponentRegistry.access$000(AbstractComponentRegistry.java:87)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:817)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponentInternal(AbstractComponentRegistry.java:221)
          at org.infinispan.factories.ComponentRegistry.registerComponentInternal(ComponentRegistry.java:192)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:176)
          at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:297)
          at org.infinispan.factories.ComponentRegistry.getOrCreateComponent(ComponentRegistry.java:165)
          at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:247)
          at org.infinispan.factories.AbstractComponentRegistry.access$000(AbstractComponentRegistry.java:87)
          at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:817)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponentInternal(AbstractComponentRegistry.java:221)
          at org.infinispan.factories.ComponentRegistry.registerComponentInternal(ComponentRegistry.java:192)
          at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:176)
          at org.infinispan.factories.InternalCacheFactory.bootstrap(InternalCacheFactory.java:104)
          at org.infinispan.factories.InternalCacheFactory.createAndWire(InternalCacheFactory.java:82)
          at org.infinispan.factories.InternalCacheFactory.createCache(InternalCacheFactory.java:66)
          at org.infinispan.manager.DefaultCacheManager.wireAndStartCache(DefaultCacheManager.java:681)
          at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:648)
          at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:544)
          at org.hibernate.cache.infinispan.InfinispanRegionFactory.getCache(InfinispanRegionFactory.java:526)
          at org.hibernate.cache.infinispan.InfinispanRegionFactory.buildQueryResultsRegion(InfinispanRegionFactory.java:247)
          at org.hibernate.cache.internal.StandardQueryCache.<init>(StandardQueryCache.java:88)
          at org.hibernate.cache.internal.StandardQueryCacheFactory.getQueryCache(StandardQueryCacheFactory.java:45)
          at org.hibernate.internal.CacheImpl.<init>(CacheImpl.java:77)
          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:177)
          ... 54 more
      
      
      

       

       

      I am sure I have configured the transactionManager correctly in Spring configuration.

       

      All codes are hosted on my Github account.

       

      hantsy/spring-sandbox · GitHub

       

      In the jpa-cache folder.

       

      There is a test(InfinispanJpaConferenceDaoImplTest) for Infinispan.

       

      Even I changed the @Cache concurrency strategy to READ_ONLY, (according to the Hibernate doc, it does not need a transaction manager look up setting), it does not work.

       

      Any help is appreciated.