Trying to use JBoss WildFly 11, Hibernate 5.3, OGM 5 and MongoDB - EAR won't deploy

643 Views Asked by At

I am trying to use JPA OGM with MongoDB.

I have added the latest version of Hibernate (5.3.0.CR1) to the WildFly 11 module folder:

/usr/local/Cellar/wildfly-as/11.0.0.Final/libexec/modules/system/layers/base/org/hibernate/5.3.0.CR1

I have added the Hibernate version to my persistence.xml

<persistence-unit name="NOTiFYwellMongoDBPersistenceUnit" transaction-type="JTA">
      <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>

        <properties>
            <property name="jboss.as.jpa.providerModule" value="org.hibernate:5.3.0.CR1"/>
            <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAS"/>
            <property name="hibernate.ogm.datastore.provider" value="org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider"/>
            <property name="hibernate.ogm.datastore.grid_dialect" value="org.hibernate.ogm.datastore.mongodb.MongoDBDialect"/>

        <property name="hibernate.ogm.datastore.database" value="notifyWellDB"/>
        <property name="hibernate.ogm.mongodb.host" value="127.0.0.1"/>
    </properties>
</persistence-unit>

When I build the EAR and have to keep adding various JARs from Hibernate and OGM to get rid the 'class not found exceptions'.

I'm now stuck with:

ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 65) MSC000001: Failed to start service jboss.persistenceunit."NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit": org.jboss.msc.service.StartException in service jboss.persistenceunit."NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit": java.util.ServiceConfigurationError: org.hibernate.boot.model.TypeContributor: Provider org.hibernate.type.Java8DateTimeTypeContributor not a subtype

Why aren't the required JARs being picked up from the modules folders and automatically loaded by the 'class loader' instead of having to manually add them to an EAR?

2

There are 2 best solutions below

0
On

Please extract this and put it in ${wildflyHome}/modules.

Then put following tag in your pom.xml:

<dependency>
    <groupId>org.hibernate.ogm</groupId>
    <artifactId>hibernate-ogm-mongodb</artifactId>
    <version>5.1.0.Final</version>
    <scope>provided</scope>
</dependency>
4
On

First thing first, Hibernate OGM 5.3 is compatible with ORM 5.2, not ORM 5.3 (ORM 5.3 is not released yet).

See our compatibility matrix here: http://hibernate.org/ogm/releases/.

Then we have a full section of the documentation explaining how to use OGM on WildFly. See https://docs.jboss.org/hibernate/stable/ogm/reference/en-US/html_single/#ogm-configuration-jbossmodule . Note that there is an error in the documentation, it is targeting WildFly 11, not 10. We will fix that for our next release.

WildFly is a modular environment so classes are not available everywhere. That's why we have carefully set up modules that you can reuse.

Update: I created https://hibernate.atlassian.net/browse/OGM-1414 to track the documentation issue.