我正在使用Jakarta ee 10测试Hibernate Search 6.2.2,但没有成功。在我目前的6.1.8版本中,没有任何问题(使用Jakarta ee 8,Hibernate 5和Payara 5运行)。我的平台是:
- Payara社区服务器- 6.2023.9
- Hibernate 6.3.1
- Hibernate search 6.2.2
- Mariadb 10+
- 雅加达ee 10
- OpenJDK 17
在我的设定和错误之下:
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> ...
型
...
错误...
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
型
...
如果有人能给给予点提示的话,我会非常感激的。
1条答案
按热度按时间n6lpvg4x1#
我猜Paraya使用了一个Hibernate搜索目前无法处理的URL模式。
参见https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#mapping-classpath-scanning-faster:
Hibernate Search的扫描可能会在应用程序启动时通过Jandex触发JAR的索引。此索引应该合理地短,但如果它导致性能问题,您可以:
hibernate.search.mapping.build_missing_discovered_jandex_indexes
设置为false
,指示Hibernate Search在启动时从不构建Jandex索引。不建议这样做,因为它可能会导致引导失败或忽略Map注解,因为Hibernate Search将不再能够自动发现在没有嵌入Jandex索引的JAR中使用根注解进行注解的类型。如果在应用上述方法后仍然出现错误,您可以尝试自定义Map,如explained in this other answer:
字符串
persistence.xml
:型
我创建了https://hibernate.atlassian.net/browse/HSEARCH-5018,以便在未来的版本中减少这种混乱。