在 Wildfly 10.1.0 上为 Mongodb 持久性部署 Hibernate OGM 时出现问题

Problems deploying Hibernate OGM for Mongodb persistence on Wildfly 10.1.0

使用 Mongodb 的 Hibernate OGM 持久性单元时,在 Wildfly 10.1.0 上部署应用程序时出现错误。在尝试了几种模块和配置的组合之后,我遵循了 .

的答案

我相信我已经正确组织了模块。 jboss-部署结构如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
  <deployment>
    <dependencies>
      <module name="org.hibernate.ogm.mongodb" services="import" />
      <module name="org.hibernate.search.orm" services="import" />
      <module name="org.hibernate.search.engine" slot="5.6" services="import" />
    </dependencies>
  </deployment>
</jboss-deployment-structure>

我的持久化单元是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">

  <persistence-unit name="ogm-mongodb" transaction-type="JTA">
    <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
    <class>org.secomm.authenticator.persistence.ServerVault</class>
    <properties>
      <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
      <property name="hibernate.ogm.datastore.provider" value="mongodb" />
      <property name="hibernate.ogm.datastore.database" value="mydatabase"/>
      <property name="hibernate.ogm.datastore.host" value="myhost"/>
      <property name="hibernate.ogm.datastore.username" value="***" />
      <property name="hibernate.ogm.datastore.password" value="***"/>
    </properties>
  </persistence-unit>
</persistence>

我收到一条错误消息,指出缺少 Hibernate 5.1 模块:

ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 1) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "secomm-enterprise-ear-1.0-SNAPSHOT.ear")]) - failure description: {
"WFLYCTL0080: Failed services" => {
    "jboss.module.service.\"deployment.secomm-enterprise-ear-1.0-SNAPSHOT.ear.secomm-api-rest-1.0-SNAPSHOT.war\".main" => "org.jboss.msc.service.StartException in service jboss.module.service.\"deployment.secomm-enterprise-ear-1.0-SNAPSHOT.ear.secomm-api-rest-1.0-SNAPSHOT.war\".main: WFLYSRV0179: Failed to load module: deployment.secomm-enterprise-ear-1.0-SNAPSHOT.ear.secomm-api-rest-1.0-SNAPSHOT.war:main
Caused by: org.jboss.modules.ModuleNotFoundException: org.hibernate:5.1"

似乎没有一个统一的 hibernate 5.1 模块包。如果我开始尝试手动添加 Hibernate 模块,它会导致搜索引擎依赖项的漏洞,最终给我一个关于 SPI 集成器 class 不是子类型的错误。

如有任何帮助,我们将不胜感激。

这是您必须下载并添加到 WildFly 的模块:

<groupId>org.hibernate</groupId> <artifactId>hibernate-orm-modules</artifactId> <version>5.1.10.Final</version> <classifier>wildfly-10-dist</classifier>

$WILDFLY_HOME/modules 中提取它,它应该可以工作。 如果您不使用 maven,可以从 JBoss Nexus 存储库下载它:https://repository.jboss.org/nexus/content/groups/public/org/hibernate/hibernate-orm-modules/5.1.10.Final/hibernate-orm-modules-5.1.10.Final-wildfly-10-dist.zip