如何在JBoss7.1中使用Infinispan查询
我有一个通过JBoss7.1 Web界面创建的Infinispan缓存.它被配置为索引的分布式缓存.
I have an Infinispan cache that I created through JBoss7.1 web interface. It is configured as an indexed, distributed cache.
在我的jboss-deployment-structure.xml
文件中,我添加了对org.infinispan
和org.hibernate
的依赖关系,因此我可以访问我的缓存.我还对以下内容添加了maven依赖项:
In my jboss-deployment-structure.xml
file I have added dependencies on org.infinispan
and org.hibernate
so I have access to my cache. I have also added a maven dependency on the following:
<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>
5.1.7.Final是我正在使用的JBoss7.1.3的org.infinispan模块中包含的版本.这会引入所有必需的依赖项(包括lucene
和hibernate-search-engine
),因此我的项目中确实具有必需的库.但是,在执行初始步骤时,在此处:>
5.1.7.Final is the version included in the org.infinispan module in JBoss7.1.3 which I am using. This pulls in all the necessary dependencies (including lucene
and hibernate-search-engine
) so I do have the necessary libs in my project. However when doing the initial step mentioned here:
SearchManager searchManager = Search.getSearchManager( cache );
它调用ComponentRegistryUtils.getComponent(cache, SearchFactoryIntegrator.class)
,但无法抛出IllegalArgumentException
:
此高速缓存上未启用索引.界面 在注册表中找不到org.hibernate.search.spi.SearchFactoryIntegrator
Indexing was not enabled on this cache. interface org.hibernate.search.spi.SearchFactoryIntegrator not found in registry
我的缓存启用了索引编制,如cache.getCacheConfiguration().indexing().enabled()
返回true
所示.但应用程序认为并非如此.也许是因为缓存的ComponentRegistry
无法访问org.hibernate.search.spi.SearchFactoryIntegrator
类(缓存是JBoss全局组件,而休眠搜索库在我的WAR的WEB-INF/lib
目录中).
My cache has indexing enabled as can be seen by cache.getCacheConfiguration().indexing().enabled()
returning true
. But the application thinks it is not. Maybe this is because the cache's ComponentRegistry
does not have access to the org.hibernate.search.spi.SearchFactoryIntegrator
class (the cache being a JBoss global component, while the hibernate search lib is in my WAR's WEB-INF/lib
directory).
还有另一种方法吗?
JBoss AS 7包含一个 org.infinispan 模块,该模块在群集子系统内部使用,但是该模块不包括 lucene 和 hibernate-search-engine 依赖项.
JBoss AS 7 includes an org.infinispan module as it's used internally by the clustering subsystem, but this module does not include the lucene and hibernate-search-engine dependencies.
通过在应用程序中指定这些依赖项,您(正确地)添加了缺少的依赖项,但是所包含的 org.infinispan 并未将扩展名视为"模块无法从应用程序的类路径加载扩展点.
By specifying those dependencies in your application you are (correctly) adding the missing dependencies, but the included org.infinispan doesn't "see" the extensions as the module can not load extension points from your application's classpath.
因此可能的解决方案是将这些依赖项添加到AS7模块中,并修补 org.infinispan 模块,以从您的自定义模块导入这些资源.
So a possible solution is to add those dependencies to the AS7 modules and patch the org.infinispan module to import these resources from your custom module.
另一种解决方案是不依赖AS包含的 org.infinispan 模块,而是将其全部包含在您的应用程序中.这样,您在使用其他版本(可能是较新的版本)时也具有更大的灵活性.
An alternative solution is to not rely on the org.infinispan module included by the AS but include it all in your application. This way you also have more flexibility on using a different version, possibly a more recent one.