I have an Infinispan cache that I created through JBoss7.1 web interface. It is configured as an indexed, distributed cache.
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 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 );
It calls ComponentRegistryUtils.getComponent(cache, SearchFactoryIntegrator.class)
which fails throwing IllegalArgumentException
:
Indexing was not enabled on this cache. interface org.hibernate.search.spi.SearchFactoryIntegrator not found in registry
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).
Is there another way I should be doing this?
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.
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.
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.
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.
I ended up excluding infinispan and hibernate (rather not including them, which amounts to the same thing) from the
jboss-deployment-structure.xml
file.Then I added a dependency in my
pom.xml
file onorg.infinispan:infinispan-query:5.2.1.Final
to pull all the jars into myWAR
artifact'sWEB-INF/lib
directory.Then I built the cache programmatically:
and added
@Field
annotation toMyObject
:and the search method:
I've found: https://community.jboss.org/message/807112#807112 I hope, it could be possibly helpful for you as well.