After updating the version of Hibernate from 4.3.11.Final to 5.4.6.Final, we get a ServiceConfigurationError exception

The final exception looks like this:

Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.jpa.event.spi.JpaIntegrator not found
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:372)
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.AggregatedServiceLoader$ClassPathOnlyAggregatedServiceLoader.getAll(AggregatedServiceLoader.java:108)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:251)
at org.hibernate.integrator.internal.IntegratorServiceImpl.(IntegratorServiceImpl.java:40)
at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:224)
at org.hibernate.cfg.Configuration.(Configuration.java:118)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.(LocalSessionFactoryBuilder.java:140)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:343)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1688)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1626)
… 60 more

A search for this variant of exclusion in Google did not yield results. How to solve this problem?

You’re using org.springframework.orm.hibernate4. … that one is the Spring component meant for Hibernate 4.

For Hibernate 4 you will need to use a different integrator.

Thanks for the answer and for the advice. And which integrator is suitable, by chance, offhand (snapshot), do not remember?

Replaced hibernate4 to hibernate5. Now swears like this:

Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.jpa.event.spi.JpaIntegrator not found
	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:372)
	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.AggregatedServiceLoader$ClassPathOnlyAggregatedServiceLoader.getAll(AggregatedServiceLoader.java:108)
	at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:251)
	at org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(IntegratorServiceImpl.java:40)
	at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:224)
	at org.springframework.orm.hibernate5.LocalSessionFactoryBean.getMetadataSources(LocalSessionFactoryBean.java:364)
	at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1688)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1626)
	... 46 more

Hi,

sorry I’ve never seen that error but it seems clear that you’re having some out of date components, likely still some wrong version of the Spring integration components.

You might want to read the spring documentation to identify which versions they suggest are compatible with a specific Hibernate ORM version; failing that ask on the Spring forums.

I found this instruction here: https://www.baeldung.com/hibernate-5-spring.
I installed versions on it:
hibernate - ‘5.4.2.Final’;
spring - ‘5.1.6.RELEASE’.
And again returned to the same error at startup:

	... 35 more
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.jpa.event.spi.JpaIntegrator not found
	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:372)
	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.AggregatedServiceLoader$ClassPathOnlyAggregatedServiceLoader.getAll(AggregatedServiceLoader.java:108)
	at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:251)
	at org.hibernate.integrator.internal.IntegratorServiceImpl.<init>(IntegratorServiceImpl.java:40)
	at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:224)
	at org.springframework.orm.hibernate5.LocalSessionFactoryBean.getMetadataSources(LocalSessionFactoryBean.java:442)
	at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:495)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
	... 48 more

The reason for this exception lies in the “org.hibernate.integrator.spi.Integrator” file. When compiling a project, the Intellij IDEA creates this file in the “/home/… …/out/production/resources/META-INF/services/” directory. It has only one line: “org.hibernate.jpa.event.spi.JpaIntegrator”. For some reason, it turns out to contain a class that is really absent in library “hibernate-core-5.4.9.Final”?

Hi @btow, have you tried to delete the /out folder?

Hi @dreab8! Yes. I deleted this directory.

In the library “hibernate-entitymanager” version “4.3.11.Final” there is a class “org.hibernate.jpa.event.spi.JpaIntegrator”, which refers to a line from the file “org.hibernate.integrator.spi.Integrator”. It implements the interface “org.hibernate.integrator.spi.Integrator” from the library “hibernate-core”. What class in the “hibernate-entitymanager” library of the “5.4.6.Final” - “5.4.10.Final” version has the “org.hibernate.jpa.event.spi.JpaIntegrator” class replaced?

from the migration guide https://github.com/hibernate/hibernate-orm/blob/5.3/migration-guide.adoc#jpaintegrator-removed

Hi @dreab8! Do I understand correctly that you just need to delete the file “org.hibernate.integrator.spi.Integrator” from the module resources? Although not. Apparently, I must independently implement the “org.hibernate.integrator.spi.Integrator” interface? Can I see different examples of its implementation somewhere? Google helps in this bad.

I deleted the package with the file that references the class “org.hibernate.jpa.event.spi.JpaIntegrator”. The error “java.util.ServiceConfigurationError” has disappeared. Instead, she got this error:

	... 48 more
Caused by: java.lang.NoSuchMethodError: javax.el.ELUtil.getExpressionFactory()Ljavax/el/ExpressionFactory;
	at javax.el.ELManager.getExpressionFactory(ELManager.java:61)
	at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:124)
	at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:78)
	at org.hibernate.validator.internal.engine.AbstractConfigurationImpl.getDefaultMessageInterpolator(AbstractConfigurationImpl.java:521)
	at org.hibernate.validator.internal.engine.AbstractConfigurationImpl.getDefaultMessageInterpolatorConfiguredWithClassLoader(AbstractConfigurationImpl.java:718)
	at org.hibernate.validator.internal.engine.AbstractConfigurationImpl.getMessageInterpolator(AbstractConfigurationImpl.java:436)
	at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:147)
	at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:38)
	at org.hibernate.validator.internal.engine.AbstractConfigurationImpl.buildValidatorFactory(AbstractConfigurationImpl.java:403)
	at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:103)
	at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:501)
	at org.hibernate.cfg.beanvalidation.TypeSafeActivator.activate(TypeSafeActivator.java:84)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:131)
	... 56 more

I found out that the javax.el.ELUtil class is in the javax.el-api library. But this class in the used version of the “2.2.4” of this library does not really contain the “getExpressionFactory()” method. I fixed the version of the library in the dependencies on “3.0.0” and this error disappeared. But a new one appeared:

	... 67 more
Caused by: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene410' does not exist.  You need to add the corresponding JAR file supporting this SPI to your classpath.  The current classpath supports the following names: [Lucene54]
	at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:114)
	at org.apache.lucene.codecs.Codec.forName(Codec.java:113)
	at org.apache.lucene.index.SegmentInfos.readCodec(SegmentInfos.java:469)
	... 81 more

Process finished with exit code 1

Now you need to catch this flea. Ideas are welcome.

Here he formulated a solution, and here he specified a new problem arising from it.