Search code examples
javamongodbhibernatewildfly-10hibernate-ogm

Problems deploying Hibernate OGM for Mongodb persistence on Wildfly 10.1.0


I am getting an error when deploying an application on Wildfly 10.1.0 when using a Hibernate OGM persistence unit for Mongodb. After trying several combinations of modules and configuration, I am following the answer to this post.

I believe I have the modules organized correctly. The jboss-deployment-structure looks like this:

<?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>

My persistence unit looks like this:

<?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>

I get an error indicating that the Hibernate 5.1 module is missing:

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"

There doesn't seem to be a single, coherent hibernate 5.1 modules package. If I start trying to add in the Hibernate modules manually, it leads down a rabbit hole of search engine dependencies that ends up giving me an error about a SPI integrator class not being a subtype.

Any help with this is appreciated.


Solution

  • This is the module you have to download and add to WildFly:

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

    Extract it in $WILDFLY_HOME/modules and it should work. If you are not using maven, you can download it from the JBoss Nexus repository: 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