本文介绍了由于SearchFactoryIntegrator不在注册表中,因此无法在JBoss 7上查询Infinispan的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL:DR我收到以下错误,我看不出它的原因,启用了索引,并且SearchFactoryIntegrator在类路径上,需要查看它。

长版本:




  • JBoss版本:7.1.1 FINAL

  • Infinispan版本:5.16(从5.1.2 JBoss升级后试用解决问题)

  • Java版本:1.7



我正在尝试构建一个简单的测试应用程序对Infinispan缓存运行查询。



我成功地将对象添加到缓存中。缓存定义为 private org.infinispan.Cache< String,Agent>缓存; 代理是我自己的对象。



当尝试查询缓存时,我从
SearchManager searchManager = Search.getSearchManager(cache);

  17:35: 43,473 ERROR [org.apache.catalina.core.ContainerBase。[jboss.web]。[default-host]。[/ SearchableCacheTest]。[Faces Servlet]](http-localhost-127.0.0.1-8080-1)Servlet。 servlet的service()Faces Servlet抛出异常:java.lang.IllegalArgumentException:未在此缓存上启用索引。在org.infinispan.query.impl.ComponentRegistryUtils.getComponent(ComponentRegistryUtils.java:40)的注册表
中找不到org.hibernate.search.spi.SearchFactoryIntegrator接口[infinispan-query-5.1.6.FINAL.jar: 5.1.6.FINAL]
at org.infinispan.query.SearchManagerImpl。< init>(SearchManagerImpl.java:56)[infinispan-query-5.1.6.FINAL.jar:5.1.6.FINAL]
at org.infinispan.query.Search.getSearchManager(Search.java:39)[infinispan-query-5.1.6.FINAL.jar:5.1.6.FINAL]

重要的部分是

此错误之前 cache.getCacheConfiguration ()。indexx()。enabled()解析为 true



缓存是已经在JBoss的 standalone-ha.xml 中配置的默认群集缓存的修改版本。

 < cache-container name =clusteraliases =ha-partitiondefault-cache =defaultstart =EAGER> 
< transport lock-timeout =60000/>
< replicated-cache name =defaultmode =SYNCbatching =trueindexing =LOCAL>
< locking isolation =REPEATABLE_READ/>
< store class =org.infinispan.loaders.file.FileCacheStorepreload =truepassivation =falsefetch-state =truepurge =false>
< property name =location>
/ tempCacheIndex
< / property>
< / store>
< / replicated-cache>
< / cache-container>

我看到索引是在配置的文件位置创建的,所以似乎启用布尔值解析为true是当前状态的事实表示。



我在JBoss中创建了一个org.infinispan.query模块,它包含以下内容




  • avro-1.5.1.jar

  • hibernate-commons-annotations-4.0.1.Final.jar

  • hibernate-search-engine-4.1.1.Final.jar

  • infinispan-query-5.1.6.FINAL.jar

  • jackson-core-asl-1.9.2.jar

  • jackson-mapper-asl-1.9.2.jar

  • lucene-core-3.5。 0.jar

  • paranamer-2.3.jar

  • slf4j-api-1.6.1.jar

  • snappy-java-1.0.4.1.jar



所有以上内容都在module.xml中作为资源根定义模块。
我修改了模块 org.infinispan 的module.xml,以依赖模块 org.infinispan.query



我已经在jboss-deployment-structure.xml中声明了这两个模块的依赖关系





注意:有一个非常相似的问题,但他最终都没有成功并选择了不同的路线。

解决方案

注意:我从一个干净的JBoss 7.1.1实例开始,因此从Infinispan 5.1.6恢复到5.1.2



根据我的需要,我修改了现有的群集缓存,使其看起来像这样

 < cache-container name = clusteraliases =ha-partition
default-cache =defaultstart =EAGER>
< transport lock-timeout =60000/>
< replicated-cache name =defaultmode =SYNCbatching =true
indexing =LOCAL>
< locking isolation =REPEATABLE_READ/>
< store class =org.infinispan.loaders.file.FileCacheStore
preload =truepassivation =falsefetch-state =truepurge =false>
< property name =location>
/ tempCacheIndex
< / property>
< / store>
< / replicated-cache>


然后实际上能够查询缓存创建包含以下module.xml中提到的jar的org.infinispan.query模块

 < module xmlns = urn:jboss:module:1.1name =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.infinispanservices =importexport =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.slf4jexport =true/>
< module name =org.jboss.logging/>
< / dependencies>


修改 org.jboss.as.clustering.infinspan 模块xml包含对新查询模块的依赖,还包括 org.hibernate 模块已经存在。因此,将以下内容添加到该文件中。

 < module name =org.hibernateservices =import/> 
< module name =org.infinispan.queryservices =import/>

您的应用的jboss-deployment-structure.xml需要添加以下依赖项

 <?xml version =1.0encoding =UTF-8?> 
< jboss-deployment-structure>
< deployment>
< dependencies>
< module export =truename =org.hibernateservices =import/>
< module export =truename =org.infinispanservices =import/>
< module export =truename =org.infinispan.queryservices =import/>
< / dependencies>
< / deployment>
< / jboss-deployment-structure>

为了对您的对象进行注释以便对它们进行索引和搜索我建议您查看样本



编辑:
更进一步说明:
要使索引对象实际共享缓存,我现在必须




  • 创建一个jar包含您计划放入缓存中的所有类。

  • 确保这些实体不包含任何过于复杂的导入条款,否则您将遇到类加载器问题。

  • 从这个jar创建一个模块,并赋予它对Infinispan.query模块的依赖。

  • 将此模块公开为全局模块(实际上是这个)需要?)在standalone.xml或domain.xml中哪个是合适的。

  • 查找文件modules / org / jboss / as / clustering / infinispan / main / module.xml

  • 将包含可缓存实体的新模块添加到lis依赖关系


TL:DR I'm getting the following error and I can see no reason for it, indexing is enabled, and the SearchFactoryIntegrator is on the classpath for everything that needs to see it.

Long Version:

  • JBoss version: 7.1.1 FINAL
  • Infinispan version: 5.16 (upgraded from 5.1.2 JBoss ships with in attempts to solve issue)
  • Java Version: 1.7

I am attempting to build a simple test application to run queries against an Infinispan cache.

I am successfully adding objects to the cache. The cache is defined as private org.infinispan.Cache<String, Agent> cache; with Agent being my own object.

When attempting to query the cache I get the following error from the line SearchManager searchManager = Search.getSearchManager(cache);

17:35:43,873 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SearchableCacheTest].[Faces Servlet]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet Faces Servlet threw exception: java.lang.IllegalArgumentException: Indexing was not enabled on this cache. interface org.hibernate.search.spi.SearchFactoryIntegrator not found in registry
    at org.infinispan.query.impl.ComponentRegistryUtils.getComponent(ComponentRegistryUtils.java:40) [infinispan-query-5.1.6.FINAL.jar:5.1.6.FINAL]
    at org.infinispan.query.SearchManagerImpl.<init>(SearchManagerImpl.java:56) [infinispan-query-5.1.6.FINAL.jar:5.1.6.FINAL]
    at org.infinispan.query.Search.getSearchManager(Search.java:39) [infinispan-query-5.1.6.FINAL.jar:5.1.6.FINAL]

The important part being

Prior to this error cache.getCacheConfiguration().indexing().enabled() resolves to true

The cache is a modified version of the default "cluster" cache already configured in the standalone-ha.xml of JBoss.

<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>
</cache-container>

I see the index being created in the configured file location so it seems that enabled boolean resolving to true is a factual representation of the current state.

I have created an org.infinispan.query module in JBoss and it contains the following

  • avro-1.5.1.jar
  • hibernate-commons-annotations-4.0.1.Final.jar
  • hibernate-search-engine-4.1.1.Final.jar
  • infinispan-query-5.1.6.FINAL.jar
  • jackson-core-asl-1.9.2.jar
  • jackson-mapper-asl-1.9.2.jar
  • lucene-core-3.5.0.jar
  • paranamer-2.3.jar
  • slf4j-api-1.6.1.jar
  • snappy-java-1.0.4.1.jar

All of the above are defined in as resource-roots in the module.xml for that module.I have modified the module.xml for the module org.infinispan to have a dependency on the module org.infinispan.query

I have declared dependencies on both those modules in my jboss-deployment-structure.xml

Does anyone have any ideas why this might be happening and perhaps have a solution?

Note: There is a very similar question here but he was ultimately unsuccessful and chose a different route.

解决方案

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

这篇关于由于SearchFactoryIntegrator不在注册表中,因此无法在JBoss 7上查询Infinispan的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 00:35