Guillaume F.
Guillaume F.

Reputation: 6473

Hibernate Search starts with Wildfly 9 but not Wildfly 10

This is a Maven project with Hibernate Search. The Servlet works perfectly on Wildfly 9.

As soon as I start it on Wildfly 10, I get a crash when Spring autowires the beans:

ERROR [ContextLoader]:351 - Context initialization failed
nested exception is java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.search.hcore.impl.HibernateSearchIntegrator not a subtype
[...]
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.search.hcore.impl.HibernateSearchIntegrator not a subtype
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:341)
    at org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(IntegratorServiceImpl.java:57)
    at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:247)
    at org.hibernate.boot.registry.StandardServiceRegistryBuilder.<init>(StandardServiceRegistryBuilder.java:73)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1915)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)

I tried different version of the declared libraries without success.

    <spring.version>4.2.6.RELEASE</spring.version>
    <spring.boot.version>1.3.5.RELEASE</spring.boot.version>
    <lucene.version>4.10.4</lucene.version> 
    <hibernate-search-orm.version>5.3.0.Final</hibernate-search-orm.version>
    <solr-core.version>4.10.4</solr-core.version>

Anyone have any idea of what's going on?

Upvotes: 2

Views: 1132

Answers (1)

Sanne
Sanne

Reputation: 6107

Both Hibernate ORM and Hibernate Search are included in WildFly since version 8.

A notable difference in WildFly 10 compared to WildFly 9 is that Hibernate Search will be automatically added to your classpath if its usage is being detected. This will make your WAR files smaller and use the latest stable versions so it's the approach I'd recommend (although I'm not a Spring user - would love to hear if it makes things harder for Spring users, please let me know on the Hibernate forums.)

The detection rule is triggered if both:

  1. You are using Hibernate as your persistence provider implementation
  2. Any of your entities are annotated with @Indexed

So I suspect your best solution is to make sure that you're not including neither Hibernate ORM nor Hibernate Search in your deployment to avoid conflicts.

If you rather prefer to use your own version of the frameworks you can set the following property to either not inject these dependencies (so to use the libraries that you bundle in your application), or you can also choose to package custom versions of these in WildFly modules and use the alternative version (you can have alternative versions with a different "slot" identifier).

wildfly.jpa.hibernate.search.module = none

This property needs to be defined in your persistence.xml.

See also the WildFly 10 JPA Reference Guide for a full description of this and similar properties.

Upvotes: 4

Related Questions