0

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?

NOTiFY
  • 1,255
  • 1
  • 20
  • 36

2 Answers2

1

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.

Guillaume Smet
  • 9,921
  • 22
  • 29
  • I was using that documentation but abandoned it due to that very reason. So all references to 'WildFly 10" should read 'WildFly 11'? – NOTiFY Mar 01 '18 at 14:21
  • Yup. We are working on fixing the doc. The version should have been updated but wasn't, it will be fixed in our next release. – Guillaume Smet Mar 01 '18 at 14:48
  • Followed referenced documenation. EAR won't deploy get: Caused by: org.jboss.modules.ModuleLoadError: org.hibernate.jipijapa-hibernate5:5.2.14.Final – NOTiFY Mar 01 '18 at 16:44
  • The link for the "Hibernate Search modules" is broken too. – NOTiFY Mar 02 '18 at 13:14
-1

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>
M.Namjo
  • 374
  • 2
  • 13