问题
I'm looking for a help to configure Wildfly 10 with Hibernate OGM and MongoDB ... I have the following error:
11:13:17,164 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.module.service."deployment.brx-plataforma.war".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.brx-plataforma.war".main: WFLYSRV0179: Failed to load module: deployment.brx-plataforma.war:main
at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:91)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
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)
Caused by: org.jboss.modules.ModuleNotFoundException: org.hibernate:ogm
at org.jboss.modules.Module.addPaths(Module.java:1093)
at org.jboss.modules.Module.link(Module.java:1449)
at org.jboss.modules.Module.relinkIfNecessary(Module.java:1477)
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:225)
at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:68)
... 5 more
11:13:17,192 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "brx-plataforma.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.module.service.\"deployment.brx-plataforma.war\".main" => "org.jboss.msc.service.StartException in service jboss.module.service.\"deployment.brx-plataforma.war\".main: WFLYSRV0179: Failed to load module: deployment.brx-plataforma.war:main
Caused by: org.jboss.modules.ModuleNotFoundException: org.hibernate:ogm"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.module.service.\"deployment.brx-plataforma.war\".main"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
There is no Hibernate OGM module for mongoDB, in fact there is no OGM module
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.brx</groupId>
<artifactId>brx-plataforma</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>brx-plataforma</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.jboss.bom>10.0.0.Final</version.jboss.bom>
</properties>
<dependencyManagement>
<dependencies>
<!-- Configuracao tools jboss -->
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-javaee7-with-tools</artifactId>
<version>${version.jboss.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Hibernate OGM - MongoDB -->
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-bom</artifactId>
<version>5.0.4.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- CDI -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<!--Jboss annotation -->
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<!--JAX-RS -->
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
<scope>provided</scope>
</dependency>
<!--JPA -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<scope>provided</scope>
</dependency>
<!--EJB -->
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<!--JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Hibernate OGM - MongoDB -->
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-mongodb</artifactId>
</dependency>
</dependencies>
<build>
<!-- Maven - Java 8 -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<!-- Java EE 6 doesn't require web.xml, Maven needs to catch up! -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
In pom.xml the dependencies of Hibernate OGM and mongoDB are described.
The following is also the configuration of jboss-deployment-structure.xml:
<deployment>
<dependencies>
<module name="org.hibernate" slot="ogm" services="import" />
<module name="org.hibernate.ogm.mongodb" services="import" />
<module name="org.hibernate.search.orm" services="import" />
</dependencies>
</deployment>
The following is also the configuration of persistence.xml
<?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="brx-plataforma" transaction-type="JTA">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<!-- Cadastro de usuario -->
<class>br.com.brx.plataforma.cadastro.usuario.entity.Pessoa</class>
<class>br.com.brx.plataforma.cadastro.usuario.entity.PessoaFisica</class>
<class>br.com.brx.plataforma.cadastro.usuario.entity.PessoaJuridica</class>
<class>br.com.brx.plataforma.cadastro.usuario.entity.Usuario</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="brxdb"/>
<property name="hibernate.ogm.datastore.host" value="localhost"/>
<property name="hibernate.ogm.datastore.port" value="27017"/>
</properties>
</persistence-unit>
I'm using wildfly-10.1.0.Final and inside it there is the modules folder ... I would like to know how to proceed ... is it necessary to put some module inside the right server? But I've tried, I do not know if I'm going wrong in the folder structure.
thanks for the help
回答1:
In your jboss-deployment-structure.xml replace:
<module name="org.hibernate" slot="ogm" services="import" />
with
<module name="org.hibernate.ogm" slot="main" services="import" />
This should work if you have the ogm modules under WILDFLY_HOME/modules/org/hibernate/ogm/main
. If you don't have them, you can download them from the Maven Central repository.
来源:https://stackoverflow.com/questions/42331201/hibernate-module-error-ogm-mongodb-and-wildfly-10