Cannot deploy Hibernate OGM (MongoDB) app to Wildf

2019-09-17 16:45发布

问题:

I develop a simple app for learning purposes. I used Wildfly 8 (and moved to 9) as my application server, Hibernate as JPA provider and MySQL as DB. The deployment worked smoothly with no problems.
Since I wanted to learn how to use MongoDB and Hibernate OGM I read several tutorials and did exactly as instructed:

  1. download and extract to modules folder
  2. Change persistence.xml to use hibernate.ogm properties
  3. Change entities' ids to use String and generated uuid's
  4. Add jboss-deployment-structure.xml (to the top EAR project):

    <jboss-deployment-structure>
        <deployment>
            <dependencies>
                <module name="org.hibernate" slot="ogm" services="export" />
                <module name="org.hibernate.ogm.mongodb" slot="main" services="export" />
            </dependencies>
        </deployment>
    </jboss-deployment-structure>
    
  5. Removed all MySQL parts from pom(s).xml

But deployment is still not working. resulting in an exception:

 20:01:38,948 INFO  [org.jboss.as.repository] (management-handler-thread - 12) WFLYDR0001: Content added at location C:\Royi\DevTools\JBoss\wildfly-9.0.0.Final\standalone\data\content\6f\6eb320cf29bae10807b7c212dc37537f35547f\content
20:01:38,952 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0027: Starting deployment of "MyProject-ear.ear" (runtime-name: "MyProject-ear.ear")
20:01:38,981 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0207: Starting subdeployment (runtime-name: "MyProject-ejb.jar")
20:01:38,981 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0207: Starting subdeployment (runtime-name: "MyProject-war.war")
20:01:38,989 INFO  [org.jboss.as.jpa] (MSC service thread 1-4) WFLYJPA0002: Read persistence.xml for MyProjectPU
20:01:39,001 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 64) WFLYJPA0003: Starting Persistence Unit Service 'MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU'
20:01:39,001 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 64) HHH000204: Processing PersistenceUnitInfo [
    name: MyProjectPU
    ...]
20:01:39,011 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 64) MSC000001: Failed to start service jboss.persistenceunit."MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU": org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.datastore.spi.DatastoreProvider]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:665)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.datastore.spi.DatastoreProvider]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:261)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:50)
    at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:34)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:105)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator$OgmDialectFactory.<init>(OgmDialectFactoryInitiator.java:44)
    at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator.initiateService(OgmDialectFactoryInitiator.java:31)
    at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator.initiateService(OgmDialectFactoryInitiator.java:25)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:105)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:95)
    at org.hibernate.ogm.service.impl.OgmJdbcServicesInitiator$OgmJdbcServicesImpl.configure(OgmJdbcServicesInitiator.java:50)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
    at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
    at org.hibernate.ogm.jpa.HibernateOgmPersistence.createContainerEntityManagerFactory(HibernateOgmPersistence.java:105)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167)
    ... 7 more
Caused by: org.hibernate.HibernateException: OGM000044: Cannot load class org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider specified via configuration property 'hibernate.ogm.datastore.provider'
    at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getClassFromString(DefaultClassPropertyReaderContext.java:130)
    at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getTypedValue(DefaultClassPropertyReaderContext.java:98)
    at org.hibernate.ogm.util.configurationreader.impl.PropertyReaderContextBase.getValue(PropertyReaderContextBase.java:90)
    at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getValue(DefaultClassPropertyReaderContext.java:28)
    at org.hibernate.ogm.datastore.impl.DatastoreProviderInitiator.initiateService(DatastoreProviderInitiator.java:48)
    at org.hibernate.ogm.datastore.impl.DatastoreProviderInitiator.initiateService(DatastoreProviderInitiator.java:28)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:105)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)
    ... 38 more
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider]
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:245)
    at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getClassFromString(DefaultClassPropertyReaderContext.java:127)
    ... 45 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:230)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:344)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:242)
    ... 46 more

20:01:39,013 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 12) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "MyProject-ear.ear")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU\": org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.datastore.spi.DatastoreProvider]
    Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.datastore.spi.DatastoreProvider]
    Caused by: org.hibernate.HibernateException: OGM000044: Cannot load class org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider specified via configuration property 'hibernate.ogm.datastore.provider'
    Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider]
    Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider"}}
20:01:39,014 ERROR [org.jboss.as.server] (management-handler-thread - 12) WFLYSRV0021: Deploy of deployment "MyProject-ear.ear" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU\": org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.datastore.spi.DatastoreProvider]
    Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.datastore.spi.DatastoreProvider]
    Caused by: org.hibernate.HibernateException: OGM000044: Cannot load class org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider specified via configuration property 'hibernate.ogm.datastore.provider'
    Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider]
    Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider"}}

EDIT
I had some progress.
For some reason maven did not like the <scope>provided</scope> on the hibernate-ogm-mongodb dependency. After I removed it, the new DB was created but now a different exception is thrown:

20:06:16,697 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "MyProject-ear.ear" (runtime-name: "MyProject-ear.ear")
20:06:18,043 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0207: Starting subdeployment (runtime-name: "MyProject-war.war")
20:06:18,043 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) WFLYSRV0207: Starting subdeployment (runtime-name: "MyProject-ejb.jar")
20:06:18,053 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) WFLYJPA0002: Read persistence.xml for MyProjectPU
20:06:18,084 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 65) WFLYJPA0003: Starting Persistence Unit Service 'MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU'
20:06:18,084 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 65) HHH000204: Processing PersistenceUnitInfo [
    name: MyProjectPU
    ...]
20:06:18,092 INFO  [org.hibernate.ogm.datastore.impl.DatastoreProviderInitiator] (ServerService Thread Pool -- 65) OGM000016: NoSQL Datastore provider: org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider
20:06:18,093 INFO  [org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider] (ServerService Thread Pool -- 65) OGM001201: Connecting to MongoDB at localhost:27017,  with a timeout set at 5000 millisecond(s)
20:06:18,094 INFO  [org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider] (ServerService Thread Pool -- 65) OGM001207: Connecting to Mongo database named [MyProjectDB].
20:06:18,096 INFO  [org.hibernate.ogm.datastore.mongodb.impl.MongoDBDatastoreProvider] (ServerService Thread Pool -- 65) OGM001206: Mongo database named [MyProjectDB] is not defined. Creating it!
20:06:18,097 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 65) MSC000001: Failed to start service jboss.persistenceunit."MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU": org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.dialect.spi.GridDialect]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117)
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:665)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.dialect.spi.GridDialect]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:261)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator$OgmDialectFactory.<init>(OgmDialectFactoryInitiator.java:44)
    at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator.initiateService(OgmDialectFactoryInitiator.java:31)
    at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator.initiateService(OgmDialectFactoryInitiator.java:25)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:105)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:95)
    at org.hibernate.ogm.service.impl.OgmJdbcServicesInitiator$OgmJdbcServicesImpl.configure(OgmJdbcServicesInitiator.java:50)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
    at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:152)
    at org.hibernate.ogm.jpa.HibernateOgmPersistence.createContainerEntityManagerFactory(HibernateOgmPersistence.java:105)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:318)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$1100(PersistenceUnitServiceImpl.java:67)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167)
    ... 7 more
Caused by: org.hibernate.HibernateException: OGM000011: Cannot instantiate GridDialect class [org.hibernate.ogm.datastore.mongodb.MongoDBDialect]
    at org.hibernate.ogm.dialect.impl.GridDialectInitiator$GridDialectInstantiator.newInstance(GridDialectInitiator.java:115)
    at org.hibernate.ogm.dialect.impl.GridDialectInitiator$GridDialectInstantiator.newInstance(GridDialectInitiator.java:64)
    at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getDefaultValue(DefaultClassPropertyReaderContext.java:116)
    at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getTypedValue(DefaultClassPropertyReaderContext.java:86)
    at org.hibernate.ogm.util.configurationreader.impl.PropertyReaderContextBase.getValue(PropertyReaderContextBase.java:90)
    at org.hibernate.ogm.util.configurationreader.impl.DefaultClassPropertyReaderContext.getValue(DefaultClassPropertyReaderContext.java:28)
    at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:61)
    at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:34)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:105)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:251)
    ... 32 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at org.hibernate.ogm.dialect.impl.GridDialectInitiator$GridDialectInstantiator.newInstance(GridDialectInitiator.java:93)
    ... 41 more

20:06:18,098 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 16) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "MyProject-ear.ear")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU\": org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.dialect.spi.GridDialect]
    Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.dialect.spi.GridDialect]
    Caused by: org.hibernate.HibernateException: OGM000011: Cannot instantiate GridDialect class [org.hibernate.ogm.datastore.mongodb.MongoDBDialect]
    Caused by: java.lang.IllegalArgumentException: argument type mismatch"}}
20:06:18,099 ERROR [org.jboss.as.server] (management-handler-thread - 16) WFLYSRV0021: Deploy of deployment "MyProject-ear.ear" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"MyProject-ear.ear/MyProject-ejb.jar#MyProjectPU\": org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.dialect.spi.GridDialect]
    Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.dialect.spi.GridDialect]
    Caused by: org.hibernate.HibernateException: OGM000011: Cannot instantiate GridDialect class [org.hibernate.ogm.datastore.mongodb.MongoDBDialect]
    Caused by: java.lang.IllegalArgumentException: argument type mismatch"}}

回答1:

I have the sme problem and I solve it adding the module dependencies in the pom.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestEntries>
                        <Dependencies>org.hibernate.ogm:5.0 services, org.hibernate.ogm.mongodb:5.0 services</Dependencies> 
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

The artifact could be maven-jar-plugin, maven-war-plugin or maven-ear-plugin depends of your project.



回答2:

You must declare the dependencies to Hibernate OGM's core and MongoDB backend module for your deployable. Check out the Hibernate OGM reference guide which has all the details.