2

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?

Guillaume F.
  • 5,905
  • 2
  • 31
  • 59

1 Answers1

4

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.

Sanne
  • 6,027
  • 19
  • 34
  • Thank you for your answer Sanne. Which Maven package should I use to have `org.hibernate.search.annotations` but not the whole ORM? Also I don't have a `persistence.xml` since everything is configured via Spring beans, I tried adding the property there with no luck. – Guillaume F. Jun 20 '16 at 09:25
  • I tried to scope Hibernate-search to provided, tried to create a persistence.xml with the property, tried various Maven configurations... been fighting with it for one whole hour, still no luck. The Exception keeps coming. – Guillaume F. Jun 20 '16 at 09:58
  • The package `org.hibernate.search.annotations` is part of Maven artifact `org.hibernate:hibernate-search-engine` (not sure how that relates though). – Sanne Jun 20 '16 at 10:36
  • 1
    WildFly indeed doesn't know about programmatic `persistence.xml` configurations, but also in this case I don't expect it to inject Hibernate Search at all. So you might be having Hibernate ORM injected by WildFly, while you're using your own provided jars for Search. Make sure that the version of Search you do bundle (don't exclude it) is a version compatible with the version of ORM. (WildFly includes ORM 5.0.x so you'll want latest Search 5.5.x - which BTW requires Apache Lucene 5.3.x or 5.4.x or 5.5.x). Feel free to share an example project for me to debug on our forums if this isn't enough! – Sanne Jun 20 '16 at 10:37
  • I am facing same issue. Is there any global place when i can disable hibernate search in windfly 10 for whole container? – Gazeciarz Sep 22 '16 at 08:18