HSEARCH000501 cannot add Custom Analyzer to perstience.xml

I’m having problems getting my custom Analyzer to work.
I created a custom Analyzer like so

public class LuceneWhitespaceLowerAnalyzer implements LuceneAnalysisConfigurer { .... }

and added it as a property to the perstience.xml like so

<persistence-unit name="XXX">
  <properties>
    <property name="hibernate.search.backend.analysis.configurer" value="class:de.xxx.services.xxx.utils.LuceneWhitespaceLowerAnalyzer"/>
  </properties>
</persistence-unit>

However when I start the service I end up with the following log message:

HSEARCH000329: Unable to apply analysis configuration: HSEARCH000501: Invalid value for configuration property 'hibernate.search.backend.analysis.configurer': 'class:de.xxx.services.xxx.utils.LuceneWhitespaceLowerAnalyzer'. CDI BeanManager not (yet) ready to use"}}

Am I using the wrong property?

What’s the full stacktrace? It should appear higher up in the logs.

Also, what’s your environment? An application server? Which one?

Thanks for the Quick Response, we’re using Wildfly as application server.
Full Stack Trace:

07:52:11,086 ERROR [org.hibernate.search.engine.reporting.spi.RootFailureCollector] (ServerService Thread Pool -- 6) HSEARCH000521: Hibernate Search encountered a failure during bootstrap; continuing for now to list all problems, but the process will ultimately be aborted.
Context: default backend
Failure:: org.hibernate.search.util.common.SearchException: HSEARCH000329: Unable to apply analysis configuration: HSEARCH000501: Invalid value for configuration property 'hibernate.search.backend.analysis.configurer': 'class:de.xxx.services.xxx.utils.LuceneWhitespaceLowerAnalyzer'. CDI BeanManager not (yet) ready to use
	at deployment.ROOT.war//org.hibernate.search.backend.lucene.impl.LuceneBackendFactory.getAnalysisDefinitionRegistry(LuceneBackendFactory.java:159)
	at deployment.ROOT.war//org.hibernate.search.backend.lucene.impl.LuceneBackendFactory.create(LuceneBackendFactory.java:77)
	at deployment.ROOT.war//org.hibernate.search.engine.common.impl.IndexManagerBuildingStateHolder.createBackend(IndexManagerBuildingStateHolder.java:128)
	at deployment.ROOT.war//org.hibernate.search.engine.common.impl.IndexManagerBuildingStateHolder.createBackends(IndexManagerBuildingStateHolder.java:69)
	at deployment.ROOT.war//org.hibernate.search.engine.common.impl.SearchIntegrationBuilderImpl.prepareBuild(SearchIntegrationBuilderImpl.java:241)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.doBootFirstPhase(HibernateOrmIntegrationBooterImpl.java:259)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.spi.HibernateOrmIntegrationBooterBehavior.bootFirstPhase(HibernateOrmIntegrationBooterBehavior.java:17)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.lambda$bootNow$7(HibernateOrmIntegrationBooterImpl.java:218)
	at java.base/java.util.Optional.orElseGet(Optional.java:369)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.bootNow(HibernateOrmIntegrationBooterImpl.java:218)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:41)
	at deployment.ROOT.war//org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)
	at deployment.ROOT.war//org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:385)
	at deployment.ROOT.war//org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
	at deployment.ROOT.war//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1259)
	at deployment.ROOT.war//org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:366)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1300(PersistenceUnitServiceImpl.java:71)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:190)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:128)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at org.wildfly.security.elytron-private@1.15.1.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:213)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: org.hibernate.search.util.common.SearchException: HSEARCH000501: Invalid value for configuration property 'hibernate.search.backend.analysis.configurer': 'class:de.xxx.services.xxx.utils.LuceneWhitespaceLowerAnalyzer'. CDI BeanManager not (yet) ready to use
	at deployment.ROOT.war//org.hibernate.search.engine.cfg.impl.AbstractConfigurationProperty.doGet(AbstractConfigurationProperty.java:61)
	at deployment.ROOT.war//org.hibernate.search.engine.cfg.impl.AbstractConfigurationProperty.getAndTransform(AbstractConfigurationProperty.java:36)
	at deployment.ROOT.war//org.hibernate.search.engine.cfg.impl.OptionalConfigurationPropertyImpl.getAndMap(OptionalConfigurationPropertyImpl.java:27)
	at deployment.ROOT.war//org.hibernate.search.backend.lucene.impl.LuceneBackendFactory.getAnalysisDefinitionRegistry(LuceneBackendFactory.java:150)
	... 31 more
Caused by: org.hibernate.resource.beans.container.internal.NotYetReadyException: CDI BeanManager not (yet) ready to use
	at deployment.ROOT.war//org.hibernate.resource.beans.container.internal.ContainerManagedLifecycleStrategy$BeanImpl.resolveContainerInstance(ContainerManagedLifecycleStrategy.java:160)
	at deployment.ROOT.war//org.hibernate.resource.beans.container.internal.ContainerManagedLifecycleStrategy$AbstractBeanImpl.initialize(ContainerManagedLifecycleStrategy.java:92)
	at deployment.ROOT.war//org.hibernate.resource.beans.container.internal.CdiBeanContainerImmediateAccessImpl.createBean(CdiBeanContainerImmediateAccessImpl.java:43)
	at deployment.ROOT.war//org.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer.createBean(AbstractCdiBeanContainer.java:64)
	at deployment.ROOT.war//org.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer.getBean(AbstractCdiBeanContainer.java:38)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmBeanContainerBeanProvider.forType(HibernateOrmBeanContainerBeanProvider.java:67)
	at deployment.ROOT.war//org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.tryResolve(BeanResolverImpl.java:198)
	at deployment.ROOT.war//org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.resolveFromFirstSuccessfulSource(BeanResolverImpl.java:162)
	at deployment.ROOT.war//org.hibernate.search.engine.environment.bean.impl.BeanResolverImpl.resolve(BeanResolverImpl.java:91)
	at deployment.ROOT.war//org.hibernate.search.engine.environment.bean.TypeAndNameBeanReference.resolve(TypeAndNameBeanReference.java:28)
	at deployment.ROOT.war//org.hibernate.search.engine.environment.bean.BeanResolver.resolve(BeanResolver.java:75)
	at java.base/java.util.Optional.map(Optional.java:265)
	at deployment.ROOT.war//org.hibernate.search.engine.cfg.impl.OptionalConfigurationPropertyImpl.lambda$getAndMap$0(OptionalConfigurationPropertyImpl.java:27)
	at deployment.ROOT.war//org.hibernate.search.engine.cfg.impl.OptionalConfigurationPropertyImpl.convert(OptionalConfigurationPropertyImpl.java:44)
	at deployment.ROOT.war//org.hibernate.search.engine.cfg.impl.AbstractConfigurationProperty.doGet(AbstractConfigurationProperty.java:44)
	... 34 more
Caused by: org.jboss.weld.exceptions.IllegalStateException: WELD-001332: BeanManager method createInstance() is not available during application initialization. Container state: STARTING
	at org.jboss.weld.core@3.1.6.Final//org.jboss.weld.bean.builtin.BeanManagerProxy.checkContainerState(BeanManagerProxy.java:235)
	at org.jboss.weld.core@3.1.6.Final//org.jboss.weld.bean.builtin.BeanManagerProxy.createInstance(BeanManagerProxy.java:186)
	at org.jboss.weld.core@3.1.6.Final//org.jboss.weld.bean.builtin.BeanManagerProxy.createInstance(BeanManagerProxy.java:64)
	at org.jboss.weld.core@3.1.6.Final//org.jboss.weld.util.ForwardingBeanManager.createInstance(ForwardingBeanManager.java:288)
	at deployment.ROOT.war//org.hibernate.resource.beans.container.internal.ContainerManagedLifecycleStrategy$BeanImpl.resolveContainerInstance(ContainerManagedLifecycleStrategy.java:155)
	... 48 more

07:52:11,101 INFO  [org.hibernate.orm.beans] (ServerService Thread Pool -- 6) HHH10005004: Stopping BeanContainer : org.hibernate.resource.beans.container.internal.CdiBeanContainerImmediateAccessImpl@76e1ce8a
07:52:11,102 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 6) MSC000001: Failed to start service jboss.persistenceunit."ROOT.war#XXX": org.jboss.msc.service.StartException in service jboss.persistenceunit."ROOT.war#XXX": javax.persistence.PersistenceException: [PersistenceUnit: XXX] Unable to build Hibernate SessionFactory
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:198)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:128)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at org.wildfly.security.elytron-private@1.15.1.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:213)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: XXX] Unable to build Hibernate SessionFactory
	at deployment.ROOT.war//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1336)
	at deployment.ROOT.war//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1262)
	at deployment.ROOT.war//org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:366)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1300(PersistenceUnitServiceImpl.java:71)
	at org.jboss.as.jpa@23.0.0.Final//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:190)
	... 10 more
Caused by: org.hibernate.search.util.common.SearchException: HSEARCH000520: Hibernate Search encountered failures during bootstrap. Failures:

    default backend: 
        failures: 
          - HSEARCH000329: Unable to apply analysis configuration: HSEARCH000501: Invalid value for configuration property 'hibernate.search.backend.analysis.configurer': 'class:de.xxx.services.xxx.utils.LuceneWhitespaceLowerAnalyzer'. CDI BeanManager not (yet) ready to use
	at deployment.ROOT.war//org.hibernate.search.engine.reporting.spi.RootFailureCollector.checkNoFailure(RootFailureCollector.java:50)
	at deployment.ROOT.war//org.hibernate.search.engine.common.impl.SearchIntegrationBuilderImpl.prepareBuild(SearchIntegrationBuilderImpl.java:243)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.doBootFirstPhase(HibernateOrmIntegrationBooterImpl.java:259)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.spi.HibernateOrmIntegrationBooterBehavior.bootFirstPhase(HibernateOrmIntegrationBooterBehavior.java:17)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.lambda$bootNow$7(HibernateOrmIntegrationBooterImpl.java:218)
	at java.base/java.util.Optional.orElseGet(Optional.java:369)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.bootNow(HibernateOrmIntegrationBooterImpl.java:218)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)
	at deployment.ROOT.war//org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:41)
	at deployment.ROOT.war//org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)
	at deployment.ROOT.war//org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:385)
	at deployment.ROOT.war//org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
	at deployment.ROOT.war//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1259)
	... 14 more

07:52:11,105 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("full-replace-deployment") failed - address: ([]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"ROOT.war#XXX\"" => "javax.persistence.PersistenceException: [PersistenceUnit: XXX] Unable to build Hibernate SessionFactory
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: XXX] Unable to build Hibernate SessionFactory
    Caused by: org.hibernate.search.util.common.SearchException: HSEARCH000520: Hibernate Search encountered failures during bootstrap. Failures:

    default backend: 
        failures: 
          - HSEARCH000329: Unable to apply analysis configuration: HSEARCH000501: Invalid value for configuration property 'hibernate.search.backend.analysis.configurer': 'class:de.xxx.services.xxx.utils.LuceneWhitespaceLowerAnalyzer'. CDI BeanManager not (yet) ready to use"}}

It seems that this code, which detects that we’re running in WildFly (basically) and that Hibernate Search must start later, didn’t work.

Now, why? From the top of my head, I can see two reasons:

  1. You started Hibernate ORM yourself, instead of letting WildFly do the work.
    Don’t do that. If you need to upgrade to a later version of Hibernate ORM, see this documentation.
  2. You have a copy of Hibernate ORM bundled with your application, and it’s causing all kinds of classloading problems, leading to the ExtendedBeanManager class being loaded twice in different classloaders, and to the instanceof in the code I linked not working.
    Don’t do that. Make sure Hibernate ORM JARs are not included in your deployment.

If none of the above works, then it’s something else, something I’ve never seen. I’ll need you to go through the code I linked in debug mode, to tell me what’s happening exactly, and to give me the value of unknownBeanManager, of Arrays.toString(unknownBeanManager.getClass().getInterfaces()), of org.hibernate.jpa.event.spi.jpa.ExtendedBeanManager.class and of org.hibernate.resource.beans.container.spi.ExtendedBeanManager.class.

Case 1 might be our Problem, the responsible colleague returns on the 20th, if we’re unable to solve the issue then, I’ll come back to this issue.

Please also report back if you are able to solve the issue: you might help others facing a similar problem :slight_smile:

Hi yrodiere,

sorry for the late reply. After some digging we can confirm you’re 2nd assumption is right.
We’re using Wildfly 23 with a Bootable JAR, as such it’s bundled within the application and causes the class loading problem. Next week we’re looking into a possible solution by moving from Wildfly to Quarkus, since it worked nicely and integrated just as well when we setup a small test project.

Thanks for your comments

1 Like