Configuring Hibernate Search with Infinispan and Wildfly
Asked Answered
W

1

8

I'm configuring Hibernate Search 5.5.5 to use Infinispan 8.2.2 on Wildfly 10. I configured only the Infinispan module in Wildfly, not the Hibernate Search module.

Inside the persistence.xml I put this configuration:

<property name="hibernate.search.infinispan.cachemanager_jndiname" value="java:jboss/infinispan/container/hibernateSearch" />
<property name="wildfly.jpa.hibernate.search.module" value="none" />

This because seems that Infinispan is used, but doesn't persist the index.

All caches are configured in domain.xml as below:

<cache-container name="hibernateSearch" default-cache="LuceneIndexesData" jndi-name="java:jboss/infinispan/hibernateSearch" statistics-enabled="false">
      <replicated-cache name="LuceneIndexesMetadata" mode="ASYNC">
          <file-store fetch-state="false" passivation="false" preload="false" purge="false" shared="false" singleton="false"/>
      </replicated-cache>
      <replicated-cache name="LuceneIndexesLocking" mode="SYNC">
           <file-store fetch-state="false" passivation="false" preload="false" purge="false" shared="false" singleton="false"/>
      </replicated-cache>
      <replicated-cache name="LuceneIndexesData" mode="ASYNC">
           <file-store fetch-state="false" passivation="false" preload="false" purge="false" shared="false" singleton="false"/>
      </replicated-cache>
 </cache-container>

in jboss-deployment-structure.xml:

<module name="org.infinispan" slot="ispn-8.2"/>
<module name="org.hibernate.search.orm" services="export" />

When I try to index all I receive this error:

UNHANDLED_EXCEPTION: java.lang.IllegalArgumentException: java.lang.Object is not an indexed entity or a subclass of an indexed entity

But If I remove this line:

<property name="wildfly.jpa.hibernate.search.module" value="none" />

I got

org.hibernate.search.exception.SearchException: Wrong configuration of directory provider: class org.infinispan.hibernate.search.spi.InfinispanDirectoryProvider does not implement interface org.hibernate.search.store.DirectoryProvider

The problem seems the same described here:

https://developer.jboss.org/thread/271789

But I don't find any working solution, and I'm sure that I havent one or more Infinispan or Hibernate version in my classpath.

What is wrong? :(

Wesleyanism answered 22/12, 2017 at 10:6 Comment(0)
H
2

TLDR; You are having 2 Infinispan versions in your classpath: one in your jboss-deployment-structure.xml and one coming with org.jboss.as.clustering subsystem.

Custom Hibernate Search

<property name="wildfly.jpa.hibernate.search.module" value="none" /> just means do not automatically use AND export app server "search" module for my app.

Thus, <module name="org.hibernate.search.orm" services="export" /> is redundant, it will be done automatically as soon as you put the correct module id for wildfly.jpa.hibernate.search.module instead of none or just remove the property to use the default search module.

The none option is there for situations, when you don't want to use the default or custom search module but bundle it within your app.

More details WildFly 10 Docs - Using Hibernate Search

Custom WildFly Infinispan subsystem

<module name="org.infinispan" slot="ispn-8.2"/> doesn't upgrade WildFly Infinispan subsystem. It only allows your app to directly use Infinispan as a library. The correct way would be one of:

  • Easy: upgrade to Wildfly 10.1 (It comes with Infinispan 8.2 and Hibernate Search 5.5 by default)
  • Hard: upgrade or modify org.jboss.as.clustering.infinispan module to use custom Infinispan version
  • Absurd: dump the cache infrastructure provided with WildFly and use your own bundled and configured within application
Haswell answered 4/1, 2018 at 11:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.