如何在JBoss7.1中使用Infinispan查询

Sha*_*Man 0 java lucene hibernate-search infinispan jboss7.x

我有一个通过JBoss7.1 Web界面创建的Infinispan缓存.它被配置为索引的分布式缓存.

在我的jboss-deployment-structure.xml文件中,我添加了依赖项org.infinispan,org.hibernate因此我可以访问我的缓存.我还在以下内容中添加了maven依赖项:

  <dependency>
     <groupId>org.infinispan</groupId>
     <artifactId>infinispan-core</artifactId>
     <version>5.1.7.Final</version>
     <scope>provided</scope>
  </dependency>
  <dependency>
     <groupId>org.infinispan</groupId>
     <artifactId>infinispan-query</artifactId>
     <version>5.1.7.Final</version>
  </dependency>
Run Code Online (Sandbox Code Playgroud)

5.1.7.Final是我正在使用的JBoss7.1.3中的org.infinispan模块中包含的版本.这将引入所有必需的依赖项(包括lucenehibernate-search-engine),因此我在项目中拥有必要的库.但是,在执行此处提到的初始步骤时:

  SearchManager searchManager = Search.getSearchManager( cache );
Run Code Online (Sandbox Code Playgroud)

它调用ComponentRegistryUtils.getComponent(cache, SearchFactoryIntegrator.class)失败抛出IllegalArgumentException:

此缓存未启用索引.接口org.hibernate.search.spi.SearchFactoryIntegrator在注册表中找不到

我的缓存启用了索引,cache.getCacheConfiguration().indexing().enabled()返回时可以看到true.但应用程序认为不是.也许这是因为缓存ComponentRegistry不能访问org.hibernate.search.spi.SearchFactoryIntegrator类(缓存是JBoss全局组件,而hibernate搜索lib在我的WAR WEB-INF/lib目录中).

还有另一种方法我应该这样做吗?

San*_*nne 5

JBoss AS 7包含一个org.infinispan模块,因为它在集群子系统内部使用,但该模块不包含lucenehibernate-search-engine依赖项.

通过在应用程序中指定这些依赖项,您(正确地)添加缺少的依赖项,包含的org.infinispan不会"看到"扩展,因为模块无法从应用程序的类路径加载扩展点.

因此,可能的解决方案是将这些依赖项添加到AS7模块并修补org.infinispan模块以从您的自定义模块导入这些资源.

另一种解决方案是不依赖于AS包含的org.infinispan模块,而是将其全部包含在您的应用程序中.这样,您在使用不同版本时也可以更灵活,可能是更新版本.