【问题标题】:Error during the deploy with wildfly-maven-plugin使用 wildfly-maven-plugin 部署期间出错
【发布时间】:2018-03-28 08:11:30
【问题描述】:

我有一个 Maven 多模块项目,其结构如下:

- cotacao
-- cotacao-core
-- cotacao-service

cotacaoproject 是根,cotacao-{core,service} 是模块。 cotacao-service 是一个 EJB 模块,它具有 cotacao-core 作为依赖项。我正在使用 wildfly-maven-plugin 来部署 EJB cotacao-service

我的pom.xml的片段是:

(1)cotacao 项目:

<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)cotacao-core 项目:

<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)cotacao-service 项目:

<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>

我正在运行以下 Maven 目标 wildfly:deploy,但出现错误:

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
}

所以,我不知道我的 Maven 配置有什么问题。如何使用wildfly-maven-plugin 来部署具有相应依赖项的 EJB?就我而言,cotacao-core 是必需的依赖项之一。

谢谢!

【问题讨论】:

  • 这不会按现在的方式工作。默认情况下,单独的部署相互隔离,因此即使您部署了cotacao-core jar,cotacao-service 也无法看到其中的类。
  • 但是,有没有办法做我想做的事?还是不可能?
  • 为什么不直接使用 EAR?

标签: maven ejb wildfly


【解决方案1】:

我还没有找到一种优雅的方式来做我想做的事。所以,我用maven-shade-plugin 解决了这个问题。该插件配置如下。有两种执行:一种用于 EJB 本身,另一种用于 EJB 客户端。

        <!-- 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>

【讨论】:

  • 你知道EAR文件是什么吗?
【解决方案2】:

在执行 wildfly:deploy 之前必须安装“cotacao-core”:

尝试更改执行安装:

<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>

然后简单地启动:mvn install

【讨论】:

  • 在此更改后,我收到错误:[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.2.0.Final:deploy-artifact (deploy-cotacao-core-dependency) on project cotacao-service: deploy-artifact must specify the artifactId
  • 尝试 mvn clean install -DartifactId=cotacao-service
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-04
  • 1970-01-01
  • 2019-03-13
相关资源
最近更新 更多