1 Reply Latest reply on Oct 10, 2011 6:42 AM by galder.zamarreno

    Best way to use Infinispan on JBossAS6?




      I'm running a Spring 3.0 war app on JBoss AS6.1, and want to add Infinispan as a Hibernate L2 cache.  I understnad that JB6 ships with Infinispan 4.x as part of the bundle.  Consequently, I'm wondering what the "right" way to use Infinispan in my app is.


      Ideally, I would like to use IS 5.0.1, so can add the dependency into my pom.xml.  I noticed that I had to exclude the jboss-transaction-api artifact from the infinispan dependency (Spring/Hibernate was complaining about not specifiying a TransactionManager or UserTransactionManager with the jboss- transaction-api included, and I figured it must have been a class loading clash with some Spring libs).


      But now, I guess the next question is what is the right step.  From the docs, I assume that I need to configure Infinispan as a standalone install (since I'm not using the JB6 packaged version), and therefore use org.hibernate.cache.infinispan.InfinispanRegionFactory as my hibernate.cache.region.factory_class (instead of the JNDI lookup class), but would like confirmation on that.


      Is there anything else I need to do or be aware of?  Is there a specific trick to configuring IS5 to use JB6's JGroups cluster channels to talk to other IS5 in the cluster while leaving JB to use IS4 to perform its own session/buddy clustering?


      When I try to launch my app with the following settings in my persistence.xml, I get a ClassCastException.




      <!-- Enable Infinispan L2 Cache -->

      <property name="hibernate.cache.use_second_level_cache" value="true" />

      <property name="hibernate.cache.use_query_cache" value="true" />

      <property name="hibernate.generate_statistics" value="true" />



      <property name="hibernate.cache.region_prefix" value="infinispan" />

      <property name="hibernate.cache.use_structured_entries" value="true" />

      <property name="hibernate.cache.use_structured_entries" value="true" />



      <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />



      <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>

      <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>



      <property name="hibernate.cache.infinispan.statistics" value="true" />







      Caused by: com.sun.xml.bind.api.AccessorException: org.infinispan.config.ConfigurationException: Unable to instantiate cache loader or configuration

                at com.sun.xml.bind.v2.runtime.reflect.AdaptedLister.addToPack(AdaptedLister.java:80) [:2.2]

                at com.sun.xml.bind.v2.runtime.unmarshaller.Scope.add(Scope.java:117) [:2.2]

                ... 108 more

      Caused by: org.infinispan.config.ConfigurationException: Unable to instantiate cache loader or configuration

                at org.infinispan.loaders.CacheLoaderConfigAdapter.unmarshal(CacheLoaderConfig.java:66) [:4.2.0.FINAL]

                at org.infinispan.loaders.CacheLoaderConfigAdapter.unmarshal(CacheLoaderConfig.java:49) [:4.2.0.FINAL]

                at com.sun.xml.bind.v2.runtime.reflect.AdaptedLister.addToPack(AdaptedLister.java:78) [:2.2]

                ... 109 more

      Caused by: java.lang.ClassCastException: org.infinispan.loaders.cluster.ClusterCacheLoader cannot be cast to org.infinispan.loaders.CacheLoader

                at org.infinispan.loaders.CacheLoaderConfigAdapter.instantiateCacheLoaderConfig(CacheLoaderConfig.java:93) [:4.2.0.FINAL]

                at org.infinispan.loaders.CacheLoaderConfigAdapter.unmarshal(CacheLoaderConfig.java:64) [:4.2.0.FINAL]

                ... 111 more



      I have a jboss-classloading.xml file in my WEB-INF/ folder in my war (see my thread at http://community.jboss.org/message/630155), but I still get the idea that I am having a class loader clash issue.



      Am I just asking for trouble using IS5 on JB6?


      Thanks for any tips and insights!




      Message was edited by: Eric B  Added ClassCastException error