9 Replies Latest reply on Oct 1, 2017 4:52 PM by sannegrinovero

    hibernate search, infinispan, jgroups, wildfly 10

    turchinc

      I am trying to get hibernate-search running with infinispan and jgroups on wildfly 10 (was running with wildfly 8.2.1 but we want to update to the lucene version offered with wildfly 10).

      We already use infinispan as a 2nd level cache in our config. 

      When I configure  hibernate search to use "ram" instead of "infinispan" it also works:

      <property name="hibernate.search.default.directory_provider" value="ram"/>

       

      In an attempt to fix this, and since I saw that infinispan-directory-provider.jar is no longer distributed with hibernate-search in Wildfly, I downloaded the infinispan modules from

      http://downloads.jboss.org/infinispan/8.2.3.Final/infinispan-as-embedded-modules-8.2.3.Final.zip

      (this was mentioned in the link referenced below) and extracted them to <WFLY>/modules.

      I then adjusted my jboss-deployment-structure.xml to include:

      <!-- hibernate search services -->

        <module name="org.infinispan" />

        <module name="org.hibernate.search.engine" services="export" slot="5.6" />

        <module name="org.hibernate.search.orm" services="export" slot="5.6" />

      The modified configuration gets picked up:

      15:46:33,568 INFO  [org.hibernate.search.engine.Version] (ServerService Thread Pool -- 81) HSEARCH000034: Hibernate Search 5.6.0.Beta1

      But I now get (I was getting ClassNotFoundException for the InfinispanDirectoryProvider):

      15:46:37,098 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 81) MSC000001: Failed to start service jboss.persistenceunit."mc.ear/web.war#mc": org.jboss.msc.service.StartException in service jboss.persistenceunit."mc.ear/web.war#mc": javax.persistence.PersistenceException: [PersistenceUnit: mc] Unable to build Hibernate SessionFactory

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: mc] Unable to build Hibernate SessionFactory

      Caused by: org.hibernate.search.exception.SearchException: HSEARCH000103: Unable to initialize IndexManager named 'Node'

      Caused by: org.hibernate.search.exception.SearchException: HSEARCH000252: Unable to initialize directory provider org.infinispan.hibernate.search.spi.InfinispanDirectoryProvider for index Node

      Caused by: java.lang.ClassCastException: org.jboss.as.clustering.infinispan.DefaultCacheContainer cannot be cast to org.infinispan.manager.EmbeddedCacheManager

        at org.infinispan.hibernate.search.impl.DefaultCacheManagerService.locateCacheManager(DefaultCacheManagerService.java:98)

        at org.infinispan.hibernate.search.impl.DefaultCacheManagerService.start(DefaultCacheManagerService.java:89)

        at org.hibernate.search.engine.service.impl.StandardServiceManager$ServiceWrapper.startService(StandardServiceManager.java:257)

        at org.hibernate.search.engine.service.impl.StandardServiceManager$ServiceWrapper.startVirtual(StandardServiceManager.java:209)

        at org.hibernate.search.engine.service.impl.StandardServiceManager.requestService(StandardServiceManager.java:83)

        at org.infinispan.hibernate.search.spi.InfinispanDirectoryProvider.initialize(InfinispanDirectoryProvider.java:66)

        at org.hibernate.search.store.spi.BaseDirectoryProviderService.initialize(BaseDirectoryProviderService.java:64)

        ... 24 more

       

      I read here:

      Hibernate Community • View topic - Problem with upgrading to Wildfly 10 & Hibernate OGM 5 

      That I should use

      org.infinispan.hibernate-search.directory-provider:for-hibernatesearch-5.5 services

       

      In my manifest instead of using the slot="5.6" but I am not sure how to translate that into jboss-deployment-structure.xml configuration?

       

      I also tried doing all of this with Wildfly-10.1.0.CR1 (thinking because it includes infinispan 8.2.3 maybe it will work better) and get just as far until I get this exception.

       

      Does anyone have advice? Thanks!

       

      Similar issues:

      Lucene Directory Cache with FileStore 

      ClassCastException in EAP 6.4 when using HibernateSearch and infinispan lucene directory

        • 1. Re: hibernate search, infinispan, jgroups, wildfly 10
          jamezp

          My guess is that there are two versions of infinispan on your class path. Maybe I just missed them, but I couldn't find instructions on how to use the 8.2.3.Final modules in WildFly.

           

          --

          James R. Perkins

          • 2. Re: hibernate search, infinispan, jgroups, wildfly 10
            jamezp

            Have you tried leaving the slot off and just using the provided version? Also make sure you're not including any of the Hibernate or Infinispan libraries in your deployment. If you're using maven just mark them as <scope>provided</scope>.

             

            --

            James R. Perkins

            • 3. Re: hibernate search, infinispan, jgroups, wildfly 10
              turchinc

              Yeah tried it without slot. Then the message [org.hibernate.search.engine.Version] is 5.5.4.Final and the error is "Unable to find directory provider implementation class: org.infinispan.hibernate.search.spi.InfinispanDirectoryProvider"


              No infinispan or HS in the ear, the provided modules was a major argument for going with wfly for us. Here is the detailed output

               

              13:33:00,360 INFO  [org.hibernate.search.engine.Version] (ServerService Thread Pool -- 73) HSEARCH000034: Hibernate Search 5.5.4.Final

              --snip--

              13:33:03,141 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 73) MSC000001: Failed to start service jboss.persistenceunit."mc.ear/web.war#mc": org.jboss.msc.service.StartException in service jboss.persistenceunit."mc.ear/web.war#mc": javax.persistence.PersistenceException: [PersistenceUnit: mc] Unable to build Hibernate SessionFactory

                Caused by: javax.persistence.PersistenceException: [PersistenceUnit: mc] Unable to build Hibernate SessionFactory

                Caused by: org.hibernate.search.exception.SearchException: HSEARCH000103: Unable to initialize IndexManager named 'Asset'

              Caused by: org.hibernate.search.exception.SearchException: Unable to find directory provider implementation class: org.infinispan.hibernate.search.spi.InfinispanDirectoryProvider

                at org.hibernate.search.util.impl.ClassLoaderHelper.classForName(ClassLoaderHelper.java:277)

                at org.hibernate.search.util.impl.ClassLoaderHelper.instanceFromName(ClassLoaderHelper.java:57)

                at org.hibernate.search.store.spi.BaseDirectoryProviderService.initialize(BaseDirectoryProviderService.java:57)

                at org.hibernate.search.store.spi.BaseDirectoryProviderService.create(BaseDirectoryProviderService.java:52)

                at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.createDirectoryProvider(DirectoryBasedIndexManager.java:230)

                at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:90)

                at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:256)

                ... 20 more



              • 4. Re: hibernate search, infinispan, jgroups, wildfly 10
                jamezp

                So you still get a ClassCastException even when leaving the slot off? That seems really weird. Maybe try removing the Infinispan 8.2.3.Final modules. There seems to be quite a few of them when I downloaded so maybe there is some kind of weird conflict.

                 

                --

                James R. Perkins

                • 5. Re: hibernate search, infinispan, jgroups, wildfly 10
                  turchinc

                  I updated my comment about the result without a slot. It was indeed a different exception:

                  Caused by: org.hibernate.search.exception.SearchException: Unable to find directory provider implementation class: org.infinispan.hibernate.search.spi.InfinispanDirectoryProvider

                  However, if I remove the slots from org.hibernate.* and add the module org.infinispan.hibernate-search.directory-provider with slot="for-hibernatesearch-5.5" (from the infinispan modules I downloadeded):

                  <!-- hibernate search services -->
                  <module name="org.infinispan" services="export"/>
                  <module name="org.hibernate.infinispan" services="export"/>
                  <module name="org.infinispan.hibernate-search.directory-provider" services="export" slot="for-hibernatesearch-5.5" />
                  <module name="org.hibernate.search.engine" services="export" />
                  <module name="org.hibernate.search.orm" services="export" />

                  Then I am back at the ClassCastException from my first post (but with the other hibernate search version.

                  17:47:04,571 INFO  [org.hibernate.search.engine.Version] (ServerService Thread Pool -- 77) HSEARCH000034: Hibernate Search 5.5.4.Final

                  17:47:06,975 WARN  [org.hibernate.search.engine.impl.ConfigContext] (ServerService Thread Pool -- 77) HSEARCH000075: Configuration setting hibernate.search.lucene_version was not specified: using LUCENE_CURRENT.

                  17:47:07,146 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 77) MSC000001: Failed to start service jboss.persistenceunit."mc.ear/web.war#mc": org.jboss.msc.service.StartException in service jboss.persistenceunit."mc.ear/web.war#mc": javax.persistence.PersistenceException: [PersistenceUnit: mc] Unable to build Hibernate SessionFactory

                  Caused by: javax.persistence.PersistenceException: [PersistenceUnit: mc] Unable to build Hibernate SessionFactory

                  Caused by: org.hibernate.search.exception.SearchException: HSEARCH000103: Unable to initialize IndexManager named 'Node'

                  Caused by: org.hibernate.search.exception.SearchException: HSEARCH000252: Unable to initialize directory provider org.infinispan.hibernate.search.spi.InfinispanDirectoryProvider for index

                  Caused by: java.lang.ClassCastException: org.jboss.as.clustering.infinispan.DefaultCacheContainer cannot be cast to org.infinispan.manager.EmbeddedCacheManager

                  • 6. Re: hibernate search, infinispan, jgroups, wildfly 10
                    pferraro

                    C. T. wrote:

                    Caused by: java.lang.ClassCastException: org.jboss.as.clustering.infinispan.DefaultCacheContainer cannot be cast to org.infinispan.manager.EmbeddedCacheManager

                    You've configured hibernate search to use a cache manager provided by WildFly (via the Infinispan subsystem), which conflicts with Infinispan jars in your application classpath.  Get rid of those Infinispan jars bundled with your deployment and you should be fine.

                    • 7. Re: hibernate search, infinispan, jgroups, wildfly 10
                      turchinc

                      My Infinispan subsystem configuration is basically 1:1 copy of standalone-full-ha.xml with the addition of the <cache-container name="hibernateSearch"..>:

                      <subsystem xmlns="urn:jboss:domain:infinispan:4.0">

                        <cache-container name="server" aliases="singleton cluster" default-cache="default" module="org.wildfly.clustering.server">... </cache-container>

                        <cache-container name="web" default-cache="dist" module="org.wildfly.clustering.web.infinispan">... </cache-container>

                        <cache-container name="ejb" aliases="sfsb" default-cache="dist" module="org.wildfly.clustering.ejb.infinispan">  ... </cache-container>

                        <cache-container name="hibernate" default-cache="local-query" module="org.hibernate.infinispan">... </cache-container>

                        <cache-container name="hibernateSearch" module="org.hibernate.infinispan" jndi-name="java:jboss/infinispan/container/hibernateSearch">... </cache-container>

                      </subsystem>

                      This was all it took in 8.2.1. 

                       

                      The EAR does not bundle any Infinispan or Hibernate JARs. Wildfly does include these in the main slots, of course. Is it conflicting with those? Perhaps I still don't completely grasp how wildfly modules and additional slots work.


                      What I am trying to accomplish is a modules based configuration in Wildfly 10 (ideally minimally impacting the base configuration) to avoid including these deps in my EAR (which worked that way with wildfly 8.2.1). AFAICT, all I really need is the infinispan directory provider, but the download from the infinispan homepage includes a whole lot more overhead than just that JAR, and the "for-hibernatesearch-5.5" module folder includes versions of

                      - infinispan-commons

                      - infinispan-core

                      - infinispan-directory-provider

                      - infinispan-lucene-directory

                      In addition, the module.xml brings dependencies to additional slots for

                              <module name="org.jboss.marshalling" slot="ispn-8.2" services="import"/>

                              <module name="org.jgroups" slot="ispn-8.2"/>

                      And indeed, both of these do have different versions in the download than in the modules/system folder (3.6.7 vs 3.6.10 and 1.4.10 vs 1.4.11).

                       

                      Do I need to remove / replace all the main infinispan jars from the main slots with the files from the "for-hibernatesearch-5.5" module to get past the conflicts?

                      • 8. Re: hibernate search, infinispan, jgroups, wildfly 10
                        sdnakhla

                        Did you ever manage to get past this?  I'm having similar issues.  In my case, I didn't install the entire set of Infinispan modules, only one for the JAR that was missing.  I was able to get it to store the indices in Infinispan, but the Infinispan cache wasn't persisting to JDBC the way I had configured it.

                        • 9. Re: hibernate search, infinispan, jgroups, wildfly 10
                          sannegrinovero

                          [I'm sorry for the late reply, this was only brought to my attention now.. answering for the sake of future people looking I guess]

                           

                          The mistake was in attempting to add the dependency to the Infinispan modules explicitly. That would introduce the (wrong) version of Infinispan on the classpath, as previously suggested.

                           

                          By downloading the right modules of Infinispan, the Hibernate Search modules are already configured to bind to them automatically - without exposing the module to the whole application so avoiding to conflict with wathever other Infinispan version one might want to use.

                           

                          Also worth noting that older versions of WildFly would introduce the Infinispan module (at slot main) on the application classpath when using Hibernate. This is no longer the case so the isolation that Hibernate Search would provide is not strictly necessary anymore - but still useful so that you can all pick a different version of Infinispan for other purposes if you wish so.