Search code examples
eclipsejakarta-eehibernate-ogm

Hibernate OGM mongodb example


I'm new to java ee, I'm searching for some example of hibernate OGM with Mongodb. I found this: https://github.com/fmarchioni/mastertheboss/tree/master/hibernateogm-mongo but I'm struggling trying to run it. Those are the steps I've done:

  • import the project in Eclipse as Maven project
  • added JavaServer Faces and Dynamic Web Module in Project Facets
  • installed Wildfly as Server runtime

Trying to run the project I get this error

13:32:49,916 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."hibernateogm-mongo.war".FIRST_MODULE_USE: org.jboss.msc.service.StartException in service jboss.deployment.unit."hibernateogm-mongo.war".FIRST_MODULE_USE: WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment "hibernateogm-mongo.war"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:151)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1736)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1698)
    at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1556)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0027: Persistence provider module load error org.hibernate.ogm (class org.hibernate.ogm.jpa.HibernateOgmPersistence)
    at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.lookupProvider(PersistenceUnitServiceHandler.java:991)
    at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.addPuService(PersistenceUnitServiceHandler.java:266)
    at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.handleWarDeployment(PersistenceUnitServiceHandler.java:206)
    at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.deploy(PersistenceUnitServiceHandler.java:134)
    at org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor.deploy(PersistenceBeginInstallProcessor.java:52)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:144)
    ... 8 more
Caused by: org.jboss.modules.ModuleNotFoundException: org.hibernate.ogm
    at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:294)
    at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:280)
    at org.jboss.as.jpa.persistenceprovider.PersistenceProviderLoader.loadProviderModuleByName(PersistenceProviderLoader.java:65)
    at org.jboss.as.jpa.processor.PersistenceUnitServiceHandler.lookupProvider(PersistenceUnitServiceHandler.java:987)
    ... 13 more

13:32:50,978 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-3) ISPN000128: Infinispan version: Infinispan 'Estrella Galicia' 9.3.1.Final
13:32:51,380 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 72) WFLYCLINF0002: Started client-mappings cache from ejb container
13:32:51,602 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 72) WFLYUT0021: Registered web context: '/wildflyDynamicProject' for server 'default-server'
13:32:51,612 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "hibernateogm-mongo.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"hibernateogm-mongo.war\".FIRST_MODULE_USE" => "WFLYSRV0153: Failed to process phase FIRST_MODULE_USE of deployment \"hibernateogm-mongo.war\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYJPA0027: Persistence provider module load error org.hibernate.ogm (class org.hibernate.ogm.jpa.HibernateOgmPersistence)
    Caused by: org.jboss.modules.ModuleNotFoundException: org.hibernate.ogm"}}

You can see the actual error is org.jboss.modules.ModuleNotFoundException: org.hibernate.ogm

Now the questions:

  • I guess org.hibernate.ogm as Maven dependency is not enough, Widlfly needs org.hibernate.ogm module. How can I install it? All the informations I find are JBoss related and outdated.
  • can I run this project in Tomcat or this makes no sense? Is Wildfly necessary in this case? I get this error in case of Tomcat 8 runtime: java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet

Solution

  • That example is quite old, I've created an up-to-date example that I'm planning to inlcude in the project on my personal repository.

    Here's the link: https://github.com/DavideD/hibernate-demos/tree/master/hibernate-ogm/nosql-with-hibernate-ogm-101/hibernate-ogm-demo-nosql-with-hibernate-ogm-101-part-3

    This project shows how to setup a maven build that prepares WildFly 13 with the appropriate modules using the provisioning plugin. It also show a basic configuration for the persistence.xml and jboss deploy descriptor.

    One thing to keep in mind, is that you need to start the server using the proprierty -Dee8.preview.mode=true as you can see in the arquillian.xml

    I hope this help