I'm testing Hibernate Search 6.2.2 with Jakarta ee 10, but not success. At my current version 6.1.8, there's no any issue(running with Jakarta ee 8, Hibernate 5, and Payara 5). My platforms are:
And below my setting and error:
persistance.xml ...
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
<persistence-unit name="myPOS1PU" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:app/jdbc/myPOSDS</jta-data-source>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
<property name="hibernate.cache.region.factory_class" value="jcache"/>
<property name="hibernate.javax.cache.provider" value="org.ehcache.jsr107.EhcacheCachingProvider"/>
<property name="hibernate.javax.cache.missing_cache_strategy" value="create"/>
<property name="hibernate.archive.autodetection" value="class, hbm, jar"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MariaDB106Dialect"/>
<property name="hibernate.dialect.storage_engine" value="innodb"/>
<property name="hibernate.id.new_generator_mappings" value="false"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.search.backend.directory.root" value="/Users/peter/hbrpos/"/>
<property name="hibernate.search.backend.io.commit_interval" value= "500"/>
<property name="hibernate.search.backend.directory.type" value= "local-filesystem"/>
<property name="jakarta.persistence.schema-generation.database.action" value="none"/>
<property name="hibernate.enhancer.enableDirtyTracking" value="false"/>
<property name="hibernate.enhancer.enableLazyInitialization" value="false"/>
</properties>
</persistence-unit>
</persistence>
...
pom.xml ...
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakartaee>10.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>${jakartaee}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jcache</artifactId>
<version>6.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm-orm6</artifactId>
<version>6.2.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-lucene</artifactId>
<version>6.2.2.Final</version>
</dependency> ...
...
Error ...
jakarta.persistence.PersistenceException: [PersistenceUnit: myPOS1PU] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1591)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1512)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:142)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:207)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:114)
at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:267)
at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:571)
at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:286)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:183)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:1255)
..
Caused by: org.hibernate.search.util.common.SearchException: HSEARCH700119: Exception while retrieving the Jandex index for code source location 'file:/Users/peter/Netbeans/Apps/myPOSNEW/target/myPOSNEW-1.7.1/WEB-INF/classes/com/mypos/authen/admin/entity/Permissions.class': HSEARCH900013: Exception while accessing Jandex index for 'file:/Users/peter/Netbeans/Apps/myPOSNEW/target/myPOSNEW-1.7.1/WEB-INF/classes/com/mypos/authen/admin/entity/Permissions.class': HSEARCH900014: Exception while building Jandex index for 'file:/Users/peter/Netbeans/Apps/myPOSNEW/target/myPOSNEW-1.7.1/WEB-INF/classes/com/mypos/authen/admin/entity/Permissions.class': HSEARCH900016: Cannot open filesystem for code source at 'file:/Users/peter/Netbeans/Apps/myPOSNEW/target/myPOSNEW-1.7.1/WEB-INF/classes/com/mypos/authen/admin/entity/Permissions.class': Provider "jar" not found
at org.hibernate.search.mapper.pojo.mapping.definition.annotation.impl.AnnotationMappingConfigurationContextImpl.jandexIndexForCodeSourceLocation(AnnotationMappingConfigurationContextImpl.java:234)
at org.hibernate.search.mapper.pojo.mapping.definition.annotation.impl.AnnotationMappingConfigurationContextImpl.buildJandexIndex(AnnotationMappingConfigurationContextImpl.java:201)
at org.hibernate.search.mapper.pojo.mapping.definition.annotation.impl.AnnotationMappingConfigurationContextImpl.lambda$configure$0(AnnotationMappingConfigurationContextImpl.java:127)
at org.hibernate.search.util.common.jar.spi.JandexBehavior.doWithJandex(JandexBehavior.java:17)
at org.hibernate.search.mapper.pojo.mapping.definition.annotation.impl.AnnotationMappingConfigurationContextImpl.configure(AnnotationMappingConfigurationContextImpl.java:126)
at org.hibernate.search.mapper.pojo.mapping.spi.AbstractPojoMappingInitiator.configure(AbstractPojoMappingInitiator.java:134)
at org.hibernate.search.mapper.orm.mapping.impl.HibernateOrmMappingInitiator.configure(HibernateOrmMappingInitiator.java:163)
at org.hibernate.search.engine.common.impl.SearchIntegrationBuilder$MappingBuildingState.collect(SearchIntegrationBuilder.java:270)
at org.hibernate.search.engine.common.impl.SearchIntegrationBuilder.prepareBuild(SearchIntegrationBuilder.java:148)
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchPreIntegrationService$NotBooted.doBootFirstPhase(HibernateSearchPreIntegrationService.java:279)
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.bootNow(HibernateOrmIntegrationBooterImpl.java:179)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147)
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:41)
at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:450)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1507)
.. 44 more
Caused by: org.hibernate.search.util.common.SearchException: HSEARCH900013: Exception while accessing Jandex index for 'file:/Users/peter/Netbeans/Apps/myPOSNEW/target/myPOSNEW-1.7.1/WEB-INF/classes/com/mypos/authen/admin/entity/Permissions.class': HSEARCH900014: Exception while building Jandex index for 'file:/Users/peter/Netbeans/Apps/myPOSNEW/target/myPOSNEW-1.7.1/WEB-INF/classes/com/mypos/authen/admin/entity/Permissions.class': HSEARCH900016: Cannot open filesystem for code source at 'file:/Users/peter/Netbeans/Apps/myPOSNEW/target/myPOSNEW-1.7.1/WEB-INF/classes/com/mypos/authen/admin/entity/Permissions.class': Provider "jar" not found
at org.hibernate.search.util.common.jar.impl.JandexUtils.readOrBuildIndex(JandexUtils.java:113)
at org.hibernate.search.mapper.pojo.mapping.definition.annotation.impl.AnnotationMappingConfigurationContextImpl.jandexIndexForCodeSourceLocation(AnnotationMappingConfigurationContextImpl.java:227)
.. 62 more
...
would be so appreciative, if someone can give a hint.
I'm guessing Payara uses a JAR URL scheme that Hibernate Search cannot handle at the moment.
Hibernate Search's scanning may trigger the indexing of JARs through Jandex on application startup. This indexing should be reasonably short, but if it causes performance issues, you can:
- Switch to the Quarkus framework, which among other things executes this part of Hibernate Search's startup at build time.
- OR execute the Jandex Maven Plugin during the build of your application, so that indexes are already built when the application starts.
- OR instruct Hibernate Search to never build Jandex indexes on startup, by setting the configuration property
hibernate.search.mapping.build_missing_discovered_jandex_indexes
tofalse
. This is not recommended as it may lead to bootstrap failures or ignored mapping annotations because Hibernate Search will no longer be able to automatically discover types annotated with root annotations in JARs that do not have an embedded Jandex index.
If you're still getting errors after applying the above, you can try customizing your mapping, like explained in this other answer:
@Dependent
@Named("searchMappingConfigurer")
public class HibernateSearchMappingConfigurer implements HibernateOrmSearchMappingConfigurer {
@Override
public void configure(HibernateOrmMappingConfigurationContext context) {
// Disable detection of @ProjectionConstructor-annotated types
// => Hibernate Search doesn't seem to be able to do that in Paraya
context.annotationMapping()
.discoverAnnotatedTypesFromRootMappingAnnotations(false);
}
}
Then in persistence.xml
:
<property name="hibernate.search.mapping.configurer" value="bean:searchMappingConfigurer"/>
I created https://hibernate.atlassian.net/browse/HSEARCH-5018 to make this less confusing in future versions.