通过尝试让 Hibernate ORM 5.2 与 OGM 5.3 一起工作进展缓慢,因此我可以将 JPA 与 MongoDB 一起使用。
要删除 OGM 常见问题解答中引用的 JNDI 查找错误:
在 WildFly 上使用 Hibernate OGM 时,我收到了 JndiException。怎么了?如果您看到 JndiException 说“无法查找 JNDI 名称 [---PlaceHolderDSForOGM---]”,则您的应用程序可能无法访问 Hibernate OGM 的应用程序服务器模块。
要更改此设置,请将以下行添加到存档的 META-INF/MANIFEST.MF 文件中(对其进行调整以匹配您选择的数据存储):
依赖:org.hibernate:ogm services, org.hibernate.ogm.mongodb services 或者,你可以通过描述符 jboss-deployment-structure.xml 来配置它。请参阅参考指南以了解更多信息。
我创建了:jboss-deployment-structure.xml
包含:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.hibernate.ogm" slot="5.3" services="export" />
<module name="org.hibernate.ogm.mongodb" slot="5.3" services="export" />
</dependencies>
</deployment>
</jboss-deployment-structure>
现在,当我尝试通过 WildFly 11 控制台部署我的 EAR 时,我得到:
17:58:42,921 错误 [org.jboss.msc.service.fail](ServerService 线程池 -- 65)MSC000001:无法启动服务 jboss.persistenceunit。“NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit”。FIRST_PHASE:服务 jboss.persistenceunit 中的 org.jboss.msc.service.StartException。“NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit”。第一阶段:java.util.ServiceConfigurationError:org.hibernate.integrator.spi.Integrator:在org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl中找不到提供程序org.hibernate.ogm.service.impl.OgmIntegrator $ 1 $ 1.run(PhaseOnePersistenceUnitServiceImpl。 java:128) at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:104) at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:640) at org.jboss .as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1.run(PhaseOnePersistenceUnitServiceImpl.java:137) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor. java:617) 在 java.lang.Thread.run(Thread.java:745) 在 org.jboss。threads.JBossThread.run(JBossThread.java:320) 原因:java.util.ServiceConfigurationError:org.hibernate.integrator.spi.Integrator:在 java.util 中找不到提供程序 org.hibernate.ogm.service.impl.OgmIntegrator。 ServiceLoader.fail(ServiceLoader.java:239) 在 java.util.ServiceLoader.access$300(ServiceLoader.java:185) 在 java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372) 在 java.util.ServiceLoader$ LazyIterator.next(ServiceLoader.java:404) at java.util.ServiceLoader$1.next(ServiceLoader.java:480) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:459) at org.hibernate.integrator.internal.IntegratorServiceImpl.(IntegratorServiceImpl.java:40) 在 org.hibernate.boot.registry.BootstrapServiceRegistryBuilder。build(BootstrapServiceRegistryBuilder.java:224) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:406) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:196) org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:32) 在 org.hibernate.jpa.boot.spi.org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:164) .Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:89) 在 org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.(TwoPhaseBootstrapImpl.java:39) 在 org.jboss.as.jpa.hibernate5.HibernatePersistenceProviderAdaptor.getBootstrap(HibernatePersistenceProviderAdaptor.java: 199)在组织。wildfly.jpa.hibernateogm5.HibernateOGMPersistenceProviderAdaptor.getBootstrap(HibernateOGMPersistenceProviderAdaptor.java:87) at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.createContainerEntityManagerFactoryBuilder(PhaseOnePersistenceUnitServiceImpl.java:254) at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl。在 org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl 访问 $900(PhaseOnePersistenceUnitServiceImpl.java:59) $1$1.run(PhaseOnePersistenceUnitServiceImpl.java:125) ... 还有 7 个PhaseOnePersistenceUnitServiceImpl.access$900(PhaseOnePersistenceUnitServiceImpl.java:59) at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:125) ... 还有 7 个PhaseOnePersistenceUnitServiceImpl.access$900(PhaseOnePersistenceUnitServiceImpl.java:59) at org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:125) ... 还有 7 个
17:58:42,926 错误 [org.jboss.as.controller.management-operation](外部管理请求线程 -- 1)WFLYCTL0013:操作(“add”)失败 - 地址:([(“deployment”=>“NOTiFYwell .ear")]) - 失败描述:{"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit\". FIRST_PHASE" => "java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.ogm.service.impl.OgmIntegrator not found 原因:java.util.ServiceConfigurationError: org.hibernate.integrator.spi .Integrator: Provider org.hibernate.ogm.service.impl.OgmIntegrator not found"}} 17:58:42,927 错误 [org.jboss.as.server](外部管理请求线程 -- 1)WFLYSRV0021:部署部署“ NOTiFYwell.ear" 已回滚并显示以下失败消息:{"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit\"。第一阶段" => "java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.ogm.service.impl.OgmIntegrator not found 原因:java.util.ServiceConfigurationError: org.hibernate.integrator.spi .Integrator: Provider org.hibernate.ogm.service.impl.OgmIntegrator not found"}} 17:58:42,939 INFO [org.jboss.as.server.deployment](MSC 服务线程 1-7)WFLYSRV0208:停止子部署( runtime-name: NOTiFYwellJAR.jar) in 10ms 17:58:42,942 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0208: Stopped subdeployment (runtime-name: NOTiFYwellWAR.war) in 13ms 17:58:42,952 INFO [org.jboss.as.server.deployment](MSC 服务线程 1-8)WFLYSRV0028:在 25 毫秒内停止部署 NOTiFYwell.ear(运行时名称:NOTiFYwell.ear)
错误:
未找到提供程序 org.hibernate.ogm.service.impl.OgmIntegrator
指在以下位置找到的类OgmIntegrator:
org/hibernate/ogm/service/impl/OgmIntegrator.class under /usr/local/Cellar/wildfly-as/11.0.0.Final/libexec/modules/system/layers/base/org/hibernate/ogm/5.3/hibernate-ogm-core-5.3.0.Final.jar
任何想法为什么没有被加载?TIA