Missing Bean when using Hibernate Search as Jar?

I have an application that uses hibernate search. I’ve been developing it locally, and it’s been working fine within IntelliJ. When I export it to a jar file and run that though, I get an issue with Hibernate Search initializing.

It gives me an error about a bean not being available for “None” for the property “hibernate.search.coordination.strategy”. The hibernate docs says this property is optional. This also isn’t a problem when I run my code from IntelliJ. Only when I compile a jar, and run it from the command line.

I’m using:

Hibernate 6.1.3

Hibernate Search 6.1.7

Hibernate Search Mapper orm orm6 6.1.7

Hibernate Search Backend Lucene 6.1.7

Here is my Hibernate.cfg file :

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <property name = "hibernate.dialect">
            org.hibernate.dialect.MySQLDialect
        </property>

        <property name="hibernate.search.default.directory_provider">
            filesystem</property>

        <property name="hibernate.search.default.indexBase">
            /var/lucene/indexes</property>

        <!-- Assume test is the database name -->

        <property name = "hibernate.connection.url">
            jdbc:mysql://redacted
        </property>

        <property name = "hibernate.connection.username">
            redacted
        </property>

        <property name = "hibernate.connection.password">
            redacted
        </property>

        <property name="hibernate.current_session_context_class">thread</property>

        <property name="hibernate.connection.CharSet">utf8</property>
        <property name="hibernate.connection.characterEncoding">utf8</property>
        <property name="hibernate.connection.useUnicode">true</property>

        <property name="show_sql">true</property>

        <!-- List of XML mapping files -->
        <mapping class="com.company.SQL_Entities.User"/>
        <mapping class="com.company.SQL_Entities.Entry_Level"/>
        <mapping class="com.company.SQL_Entities.Dictionary_Entry"/>
        <mapping class="com.company.SQL_Entities.Dictionary_Translation"/>
        <mapping class="com.company.SQL_Entities.Language"/>
        <mapping class="com.company.SQL_Entities.Study_Progress"/>
        <mapping class="com.company.SQL_Entities.Level_Classification"/>
        <mapping class="com.company.SQL_Entities.Alternate_Dictionary_Entry_Reading"/>
        <mapping class="com.company.SQL_Entities.Study_List"/>
        <mapping class="com.company.SQL_Entities.Study_List_Element"/>
        <mapping class="com.company.SQL_Entities.Character_Stroke"/>
        <mapping class="com.company.SQL_Entities.Study_List_History"/>
        <mapping class="com.company.SQL_Entities.Study_Element_Type"/>
        <mapping class="com.company.SQL_Entities.Element_Attribute_Definition"/>
        <mapping class="com.company.SQL_Entities.Study_Element_Attribute"/>
        <mapping class="com.company.SQL_Entities.Avatar_Component"/>
        <mapping class="com.company.SQL_Entities.User_Avatar"/>
        <mapping class="com.company.SQL_Entities.Obtained_Avatar_Component"/>
        <mapping class="com.company.SQL_Entities.Sub_Entry"/>
        <mapping class="com.company.SQL_Entities.Available_Study_Directions"/>
        <mapping class="com.company.SQL_Entities.Language_Level"/>
    </session-factory>
</hibernate-configuration>

I use Mavern for the dependencies if that’s helpful. Here’s my full pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <properties>
        <java.version>18</java.version>
    </properties>

    <groupId>groupId</groupId>
    <artifactId>KanjiBattleServer</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>18</source>
                    <target>18</target>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>18</source>
                    <target>18</target>
                    <compilerArguments>
                        <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                    </compilerArguments>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>4.0.0</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.29</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>6.1.3.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>6.1.3.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.search</groupId>
            <artifactId>hibernate-search-mapper-orm-orm6</artifactId>
            <version>6.1.7.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.search</groupId>
            <artifactId>hibernate-search-backend-lucene</artifactId>
            <version>6.1.7.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.search</groupId>
            <artifactId>hibernate-search-mapper-orm-coordination-outbox-polling-orm6</artifactId>
            <version>6.1.7.Final</version>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>5.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-scratchpad</artifactId>
            <version>5.0.0</version>
        </dependency>


        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>4.2.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.1.53.Final</version>
        </dependency>


    </dependencies>


</project>

I’m not sure if it’s an issue with how I’m building the jar or what, since other dependencies seem to do fine ( like Netty ).

Below is the full error:

java.lang.ExceptionInInitializerError
        at com.company.Utils.AdminServerConnections.getUserFromDB(AdminServerConnections.java:73)   
        at com.company.Utils.AdminServerConnections.getUser(AdminServerConnections.java:38)
        at com.company.ConnectionResponse.processAdminCommand(ConnectionResponse.java:93)
        at com.company.AdminConnectionHandler.channelRead(AdminConnectionHandler.java:68)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerCont
ext.java:357)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302)   
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerCont
ext.java:357)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:1
03)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerCont
ext.java:357)
        at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.ja
va:93)
        at io.netty.handler.codec.http.websocketx.Utf8FrameValidator.channelRead(Utf8FrameValidator.
java:82)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerCont
ext.java:357)
        at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandshakeHandler.channelRea
d(WebSocketServerProtocolHandshakeHandler.java:65)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerCont
ext.java:357)
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerCont
ext.java:357)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:1
03)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerCont
ext.java:357)
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannel
Read(CombinedChannelDuplexHandler.java:436)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324
)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)   
        at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.ja
va:251)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerCont
ext.java:357)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.ja
va:1410)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerCo
ntext.java:365)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) 
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.jav
a:166)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)    
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:9
89)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)    
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.hibernate.search.util.common.SearchException: HSEARCH000501: Invalid value for config
uration property 'hibernate.search.coordination.strategy': ''. HSEARCH000579: Unable to resolve bean
 reference to type 'org.hibernate.search.mapper.orm.coordination.common.spi.CoordinationStrategy' an
d name 'none'. Failed to resolve bean from Hibernate Search's internal registry with exception: HSEA
RCH000578: No beans defined for type 'org.hibernate.search.mapper.orm.coordination.common.spi.Coordi
nationStrategy' and name 'none' in Hibernate Search's internal registry. Failed to resolve bean from
 bean manager with exception: HSEARCH000590: No configured bean manager. Failed to resolve bean from
 bean manager with exception: HSEARCH000591: Unable to resolve 'none' to a class extending 'org.hibe
rnate.search.mapper.orm.coordination.common.spi.CoordinationStrategy': HSEARCH000530: Unable to load
 class 'none': Could not load requested class : none Failed to resolve bean using reflection with ex
ception: HSEARCH000591: Unable to resolve 'none' to a class extending 'org.hibernate.search.mapper.o
rm.coordination.common.spi.CoordinationStrategy': HSEARCH000530: Unable to load class 'none': Could 
not load requested class : none
        at org.hibernate.search.engine.cfg.impl.AbstractConfigurationProperty.doGet(AbstractConfigur
ationProperty.java:61)
        at org.hibernate.search.engine.cfg.impl.AbstractConfigurationProperty.getAndTransform(Abstra
ctConfigurationProperty.java:36)
        at org.hibernate.search.mapper.orm.coordination.impl.CoordinationConfigurationContextImpl.co
nfigure(CoordinationConfigurationContextImpl.java:38)
        at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchPreIntegrationService.coord
inationStrategyConfiguration(HibernateSearchPreIntegrationService.java:193)
        at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchCompositeMappingProducer.pr
oduceAdditionalMappings(HibernateSearchCompositeMappingProducer.java:50)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingPro
cess.java:329)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProces
s.java:97)
        at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:402)      
        at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:90)       
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:735)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:773)
        at com.company.UtilDatabase.<clinit>(UtilDatabase.java:18)
        ... 52 more
Caused by: org.hibernate.search.engine.environment.bean.spi.BeanNotFoundException: HSEARCH000579: Un
able to resolve bean reference to type 'org.hibernate.search.mapper.orm.coordination.common.spi.Coor
dinationStrategy' and name 'none'. Failed to resolve bean from Hibernate Search's internal registry 
with exception: HSEARCH000578: No beans defined for type 'org.hibernate.search.mapper.orm.coordinati
on.common.spi.CoordinationStrategy' and name 'none' in Hibernate Search's internal registry. Failed 
to resolve bean from bean manager with exception: HSEARCH000590: No configured bean manager. Failed 
to resolve bean from bean manager with exception: HSEARCH000591: Unable to resolve 'none' to a class
 extending 'org.hibernate.search.mapper.orm.coordination.common.spi.CoordinationStrategy': HSEARCH00
0530: Unable to load class 'none': Could not load requested class : none Failed to resolve bean usin
g reflection with exception: HSEARCH000591: Unable to resolve 'none' to a class extending 'org.hiber
nate.search.mapper.orm.coordination.common.spi.CoordinationStrategy': HSEARCH000530: Unable to load 
class 'none': Could not load requested class : none
        at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.resolveFromFirstSucces
sfulSource(BeanResolverImpl.java:173)
        at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.resolve(BeanResolverIm
pl.java:91)
        at org.hibernate.search.engine.environment.bean.TypeAndNameBeanReference.resolve(TypeAndName
BeanReference.java:28)
        at org.hibernate.search.engine.environment.bean.BeanResolver.resolve(BeanResolver.java:75)  
        at org.hibernate.search.engine.cfg.impl.DefaultedConfigurationProperty.convert(DefaultedConf
igurationProperty.java:27)
        at org.hibernate.search.engine.cfg.impl.AbstractConfigurationProperty.doGet(AbstractConfigur
ationProperty.java:44)
        ... 63 more
        Suppressed: org.hibernate.search.engine.environment.bean.spi.BeanNotFoundException: HSEARCH0
00590: No configured bean manager.
                at org.hibernate.search.engine.environment.bean.impl.NoConfiguredBeanManagerBeanProv
ider.forTypeAndName(NoConfiguredBeanManagerBeanProvider.java:37)
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.tryResolve(Bea
nResolverImpl.java:196)
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.resolveFromFir
stSuccessfulSource(BeanResolverImpl.java:162)
                ... 68 more
        Suppressed: org.hibernate.search.engine.environment.bean.spi.BeanNotFoundException: HSEARCH0
00591: Unable to resolve 'none' to a class extending 'org.hibernate.search.mapper.orm.coordination.c
ommon.spi.CoordinationStrategy': HSEARCH000530: Unable to load class 'none': Could not load requeste
d class : none
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.toClass(BeanRe
solverImpl.java:211)
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.tryResolve(Bea
nResolverImpl.java:198)
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.resolveFromFir
stSuccessfulSource(BeanResolverImpl.java:162)
                ... 68 more
        Caused by: org.hibernate.search.engine.environment.classpath.spi.ClassLoadingException: HSEA
RCH000530: Unable to load class 'none': Could not load requested class : none
                at org.hibernate.search.engine.environment.classpath.spi.DefaultClassResolver.classF
orName(DefaultClassResolver.java:39)
                at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmClassLoaderServiceClas
sAndResourceAndServiceResolver.classForName(HibernateOrmClassLoaderServiceClassAndResourceAndService
Resolver.java:60)
                at org.hibernate.search.engine.environment.classpath.spi.ClassLoaderHelper.classForN
ame(ClassLoaderHelper.java:174)
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.toClass(BeanRe
solverImpl.java:208)
                ... 70 more
        Caused by: java.lang.ClassNotFoundException: Could not load requested class : none
                at org.hibernate.search.engine.environment.classpath.spi.AggregatedClassLoader.findC
lass(AggregatedClassLoader.java:108)
                at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
                at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
                at java.base/java.lang.Class.forName0(Native Method)
                at java.base/java.lang.Class.forName(Class.java:488)
                at java.base/java.lang.Class.forName(Class.java:467)
                at org.hibernate.search.engine.environment.classpath.spi.DefaultClassResolver.classF
orName(DefaultClassResolver.java:36)
                ... 73 more
        Suppressed: org.hibernate.search.engine.environment.bean.spi.BeanNotFoundException: HSEARCH0
00591: Unable to resolve 'none' to a class extending 'org.hibernate.search.mapper.orm.coordination.c
ommon.spi.CoordinationStrategy': HSEARCH000530: Unable to load class 'none': Could not load requeste
d class : none
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.toClass(BeanRe
solverImpl.java:211)
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.tryResolve(Bea
nResolverImpl.java:200)
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.resolveFromFir
stSuccessfulSource(BeanResolverImpl.java:162)
                ... 68 more
        Caused by: org.hibernate.search.engine.environment.classpath.spi.ClassLoadingException: HSEA
RCH000530: Unable to load class 'none': Could not load requested class : none
                at org.hibernate.search.engine.environment.classpath.spi.DefaultClassResolver.classF
orName(DefaultClassResolver.java:39)
                at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmClassLoaderServiceClas
sAndResourceAndServiceResolver.classForName(HibernateOrmClassLoaderServiceClassAndResourceAndService
Resolver.java:60)
                at org.hibernate.search.engine.environment.classpath.spi.ClassLoaderHelper.classForN
ame(ClassLoaderHelper.java:174)
                at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.toClass(BeanRe
solverImpl.java:208)
                ... 70 more
        Caused by: java.lang.ClassNotFoundException: Could not load requested class : none
                at org.hibernate.search.engine.environment.classpath.spi.AggregatedClassLoader.findC
lass(AggregatedClassLoader.java:108)
                at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
                at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
                at java.base/java.lang.Class.forName0(Native Method)
                at java.base/java.lang.Class.forName(Class.java:488)
                at java.base/java.lang.Class.forName(Class.java:467)
                at org.hibernate.search.engine.environment.classpath.spi.DefaultClassResolver.classF
orName(DefaultClassResolver.java:36)
                ... 73 more
Caused by: org.hibernate.search.engine.environment.bean.spi.BeanNotFoundException: HSEARCH000578: No
 beans defined for type 'org.hibernate.search.mapper.orm.coordination.common.spi.CoordinationStrateg
y' and name 'none' in Hibernate Search's internal registry.
        at org.hibernate.search.engine.environment.bean.impl.ConfigurationBeanRegistry.resolve(Confi
gurationBeanRegistry.java:53)
        at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.tryResolve(BeanResolve
rImpl.java:194)
        at org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.resolveFromFirstSucces
sfulSource(BeanResolverImpl.java:162)
        ... 68 more

If I add these to the cfg file:

<property name="hibernate.search.indexing_strategy">
            manual
        </property>
<property name="hibernate.search.autoregister_listeners">
 false
 </property>

Then hibernate just hangs on initalization:

Sep 21, 2022 4:01:23 PM org.hibernate.Version logVersion
2022-09-21T16:01:23.875154042Z INFO: HHH000412: Hibernate ORM core version [WORKING]
2022-09-21T16:01:26.912177938Z Sep 21, 2022 4:01:26 PM org.hibernate.resource.beans.spi.ManagedBeanRegistryInitiator resolveBeanContainer
2022-09-21T16:01:26.912258428Z INFO: HHH10005002: No explicit CDI BeanManager reference was passed to Hibernate, but CDI is available on the Hibernate ClassLoader.
2022-09-21T16:01:27.891447504Z Sep 21, 2022 4:01:27 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
2022-09-21T16:01:27.891512292Z WARN: HHH10001002: Using built-in connection pool (not intended for production use)
2022-09-21T16:01:28.012261050Z Sep 21, 2022 4:01:27 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2022-09-21T16:01:28.014774201Z INFO: HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver
2022-09-21T16:01:28.024506455Z Sep 21, 2022 4:01:28 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2022-09-21T16:01:28.024654286Z INFO: HHH10001012: Connecting with JDBC URL [jdbc:mysql://redacted]
2022-09-21T16:01:28.025905012Z Sep 21, 2022 4:01:28 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2022-09-21T16:01:28.026924803Z INFO: HHH10001001: Connection properties: {password=****, useUnicode=true, CharSet=utf8, characterEncoding=utf8, user=redacted}
2022-09-21T16:01:28.034214783Z Sep 21, 2022 4:01:28 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2022-09-21T16:01:28.034692803Z INFO: HHH10001003: Autocommit mode: false
2022-09-21T16:01:28.058963415Z Sep 21, 2022 4:01:28 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
2022-09-21T16:01:28.059023531Z INFO: HHH10001115: Connection pool size: 20 (min=1)
2022-09-21T16:01:37.867009350Z Sep 21, 2022 4:01:37 PM org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl logSelectedDialect
2022-09-21T16:01:37.867077268Z INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2022-09-21T16:01:41.066756842Z Sep 21, 2022 4:01:41 PM org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchPreIntegrationService$Initiator initiateService
2022-09-21T16:01:41.066922753Z INFO: HSEARCH000034: Hibernate Search version 6.1.5.Final
2022-09-21T16:01:41.228321482Z Sep 21, 2022 4:01:41 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PoolState stop
2022-09-21T16:01:41.228589690Z INFO: HHH10001008: Cleaning up connection pool [jdbc:mysql://redacted]

and it never finishes the initalization

I confirm something is probably wrong with your setup.

The core of the problem is this:

Caused by: org.hibernate.search.engine.environment.bean.spi.BeanNotFoundException: HSEARCH000578: No
 beans defined for type 'org.hibernate.search.mapper.orm.coordination.common.spi.CoordinationStrateg
y' and name 'none' in Hibernate Search's internal registry.

Hibernate Search has an internal registry of (named) beans that should always be available, and in your case some beans that should be there seem to be missing.

The way this particular bean get registered is through the class org.hibernate.search.mapper.orm.impl.HibernateOrmBeanConfigurer, which should get loaded automatically through the service-loader thanks to the file META-INF/services/org.hibernate.search.engine.environment.bean.spi.BeanConfigurer which you can find in the hibernate-search-mapper-orm JAR.

If I had to guess, I would say that when you say “I export it to a jar file”, you are somehow shading all libraries into your JAR (putting all classes and resources into the same JAR), and for some reason the thing that does the shading does not correctly concatenate files in META-INF/services, but instead just takes one at random. Am I right?

If I’m wrong, I would suggest running the application with that “generate JAR” in debug mode and putting a breakpoint in org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl#create to see what’s going on (which BeanConfigurer instances are found, in particular).

Man I’ve been hitting my head against a wall for 3 days to figure this out, and you figured it out in like 5 minutes :joy:

opening up the jar and adding “org.hibernate.search.mapper.orm.impl.HibernateOrmBeanConfigurer” to “META-INF/services/org.hibernate.search.engine.environment.bean.spi.BeanConfigurer” absolutely did the trick.

Now to just figure out why IntelliJ isn’t packaging things correctly. Thank you so much for the help

1 Like

as addition :sweat_smile: since your solutions doesn’t work for my case
the solution for my problem was for to add a appending transformer to my shade config in my pom see code below thx @yrodiere your post guide me the way to this solution

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>${maven-shade-plugin.version}</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>shade</goal>
      </goals>
      <configuration>
        <transformers>
          ....
          <transformer
            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
            <resource>
              META-INF/services/org.hibernate.search.engine.environment.bean.spi.BeanConfigurer
            </resource>
          </transformer>
        </transformers>
        <filters>
          <filter>
               …
          </filter>
        </filters>
      </configuration>
    </execution>
  </executions>
</plugin>