Unable to query Infinispan on JBoss 7 due to SearchFactoryIntegrator not being in the registry

久未见 提交于 2019-12-05 21:38:42

NOTE: I started with a clean JBoss 7.1.1 instance and hence reverted from Infinispan 5.1.6 to 5.1.2

For my needs I modified the existing cluster cache so it looks like this

<cache-container name="cluster" aliases="ha-partition"
default-cache="default" start="EAGER">
<transport lock-timeout="60000" />
<replicated-cache name="default" mode="SYNC" batching="true"
    indexing="LOCAL">
    <locking isolation="REPEATABLE_READ" />
    <store class="org.infinispan.loaders.file.FileCacheStore"
        preload="true" passivation="false" fetch-state="true" purge="false">
        <property name="location">
            /tempCacheIndex
        </property>
    </store>
</replicated-cache>

Then to actually be able to query the cache create the org.infinispan.query module containing the jars mentioned in the following module.xml

<module xmlns="urn:jboss:module:1.1" name="org.infinispan.query">
<resources>
    <resource-root path="avro-1.5.1.jar"/>
    <resource-root path="hibernate-commons-annotations-4.0.1.Final.jar"/>
    <resource-root path="hibernate-search-4.1.0.Beta1.jar"/>
    <resource-root path="hibernate-search-analyzers-4.1.0.Beta1.jar"/>
    <resource-root path="hibernate-search-engine-4.1.0.Beta1.jar"/>
    <resource-root path="hibernate-search-orm-4.1.0.Beta1.jar"/>
    <resource-root path="infinispan-query.jar"/>
    <resource-root path="jackson-core-asl-1.9.2.jar"/>
    <resource-root path="jackson-mapper-asl-1.9.2.jar"/>
    <resource-root path="lucene-analyzers-3.5.0.jar"/>
    <resource-root path="lucene-core-3.5.0.jar"/>
    <resource-root path="lucene-grouping-3.5.0.jar"/>
    <resource-root path="lucene-highlighter-3.5.0.jar"/>
    <resource-root path="lucene-memory-3.5.0.jar"/>
    <resource-root path="lucene-misc-3.5.0.jar"/>
    <resource-root path="lucene-smartcn-3.5.0.jar"/>
    <resource-root path="lucene-spatial-3.5.0.jar"/>
    <resource-root path="lucene-spellchecker-3.5.0.jar"/>
    <resource-root path="lucene-stempel-3.5.0.jar"/>
    <resource-root path="paranamer-2.3.jar"/>
    <resource-root path="slf4j-api-1.6.1.jar"/>
    <resource-root path="snappy-java-1.0.4.1.jar"/>
    <resource-root path="solr-analysis-extras-3.5.0.jar"/>
    <resource-root path="solr-commons-csv-3.5.0.jar"/>
    <resource-root path="solr-core-3.5.0.jar"/>
    <resource-root path="solr-solrj-3.5.0.jar"/>
</resources>

<dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
    <module name="org.hibernate"/>
    <module name="org.infinispan" services="import" export="true"/>
    <module name="org.apache.commons.codec"/>
    <module name="org.apache.commons.io"/>
    <module name="org.apache.commons.lang"/>
    <module name="com.google.guava"/>
    <module name="org.slf4j" export="true"/>
    <module name="org.jboss.logging"/>
</dependencies>

Modify the org.jboss.as.clustering.infinspan module xml to include a dependency on the new query module but also the org.hibernate module that already exists. So add the following to that file.

<module name="org.hibernate" services="import"/>
<module name="org.infinispan.query" services="import"/>

The jboss-deployment-structure.xml of your app needs to have the following dependencies added to it

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
         <dependencies>
              <module export="true" name="org.hibernate" services="import"/>
              <module export="true" name="org.infinispan" services="import"/>
              <module export="true" name="org.infinispan.query" services="import"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure>

For annotating your objects so they can be indexed and searched I suggest you look at the samples here

EDIT: FURTHER NOTE: To get indexed objects to actually share over the cache I now had to

  • Create a jar containing all the classes that you plan to put in the cache.
  • Make sure these entities do not contain anything too complex it terms of imports or you'll run into class loader issues.
  • Create a module from this jar, and give it a dependency on the Infinispan.query module.
  • Expose this module as a global module (is this actually needed?) in the standalone.xml or domain.xml whichever is appropriate.
  • Find the file modules/org/jboss/as/clustering/infinispan/main/module.xml
  • Add your new module containing your cachable entities to the list of dependencies
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!