I have a Maven multimodule project with the following structure:
- cotacao
-- cotacao-core
-- cotacao-service
The cotacao
project is the root, and cotacao-{core,service}
are modules. The cotacao-service
is an EJB module that has the cotacao-core
as a dependency. I'm using wildfly-maven-plugin
to deploy the EJB cotacao-service
.
Snippets of my pom.xml
are:
(1) The cotacao
project:
<groupId>com.tnas</groupId>
<artifactId>cotacao</artifactId>
<version>1.0</version>
<name>Cotacao Parent Project</name>
<packaging>pom</packaging>
<modules>
<module>cotacao-service</module>
<module>cotacao-core</module>
</modules>
(2) The cotacao-core
project:
<parent>
<groupId>com.tnas</groupId>
<artifactId>cotacao</artifactId>
<version>1.0</version>
</parent>
<groupId>com.fincatto</groupId>
<artifactId>cotacao-core</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Cotacao Core</name>
(3) The cotacao-service
project:
<parent>
<groupId>com.tnas</groupId>
<artifactId>cotacao</artifactId>
<version>1.0</version>
</parent>
<artifactId>cotacao-service</artifactId>
<version>1.0.0</version>
<packaging>ejb</packaging>
...
<dependencies>
...
<dependency>
<groupId>com.fincatto</groupId>
<artifactId>cotacao</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${wildfly.plugin.version}</version>
<executions>
<execution>
<id>deploy-cotacao-core-dependency</id>
<phase>package</phase>
<goals>
<goal>deploy-artifact</goal>
</goals>
</execution>
</executions>
<configuration>
<project>
<dependencies>
<dependency>
<groupId>com.fincatto</groupId>
<artifactId>cotacao-core</artifactId>
</dependency>
</dependencies>
</project>
</configuration>
</plugin>
...
</plugins>
</build>
I'm running the followin Maven goal wildfly:deploy
and I'm getting the error:
15:34:03,183 ERROR [org.jboss.as.server] (management-handler-thread - 36) WFLYSRV0021: Deploy of deployment "cotacao-service-1.0.0.jar" was rolled back with the following failure message:
{
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"cotacao-service-1.0.0.jar\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"cotacao-service-1.0.0.jar\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"cotacao-service-1.0.0.jar\"
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class com.tnas.cotacao.service.BACENService with ClassLoader ModuleClassLoader for Module \"deployment.cotacao-service-1.0.0.jar:main\" from Service Module Loader
Caused by: java.lang.NoClassDefFoundError: Lcom/fincatto/cotacao/ws/WSConsulta;
Caused by: java.lang.ClassNotFoundException: com.fincatto.cotacao.ws.WSConsulta from [Module \"deployment.cotacao-service-1.0.0.jar:main\" from Service Module Loader]"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"cotacao-service-1.0.0.jar\".POST_MODULE"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
So, I don't know what's the problem with my Maven configurations. How can I use the wildfly-maven-plugin
in order to deploy an EJB with the respective dependencies? In my case, the cotacao-core
is one of the required dependencies.
Thanks!
You must 'cotacao-core' installed before do wildfly:deploy:
Try to change execution to install:
<dependencies>
...
<dependency>
<groupId>com.fincatto</groupId>
<artifactId>cotacao-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${wildfly.plugin.version}</version>
<executions>
<execution>
<id>deploy-cotacao-core-dependency</id>
<phase>install</phase>
<goals>
<goal>deploy-artifact</goal>
</goals>
</execution>
</executions>
<configuration>
<groupId>com.fincatto</groupId>
<artifactId>cotacao-service</artifactId>
</dependency>
</configuration>
</plugin>
...
</plugins>
And simply launches : mvn install
I've not found out an elegant way of doing what I want. So, I've worked around this problem with the maven-shade-plugin
. The plugin was configured as follow. There are two executions: one for the EJB itself, and another one for the EJB client.
<!-- Usage: mvn:package -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${shade.plugin.version}</version>
<executions>
<execution>
<id>shade-ejb-service</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${ejb.fileName}.jar</outputFile>
<artifactSet>
<includes>
<!-- Here I've included every dependencies -->
<include>groupId:artifactId</include>
</includes>
</artifactSet>
</configuration>
</execution>
<execution>
<id>shade-ejb-client</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${ejb.fileName}-client.jar</outputFile>
<artifactSet>
<includes>
<!-- Only dependencies for the client -->
<include>groupId:artifactId</include>
</includes>
</artifactSet>
<!-- Filters for selecting specific client classes -->
<filters>
<filter>
<artifact>com.fincatto:cotacao-core</artifact>
<includes>
<include>com/fincatto/cotacao/classes/*</include>
</includes>
</filter>
<filter>
<artifact>com.tnas:cotacao-service</artifact>
<includes>
<include>com/tnas/cotacao/service/remote/*</include>
</includes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.