You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maven构建TIBCO BW6应用显示成功但未生成.ear文件

构建TIBCO BW6 EAR文件失败问题排查与修复

问题描述

尝试构建TIBCO BW6应用的.ear文件,对应的pom.xml配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.tibco.bw</groupId>
  <artifactId>ee.entEvent.eventMsg.vendorNetcool.application.parent</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <modules>
   <!-- <module>../sm.baseSchemas</module> 
    <module>../sm.cleClient</module>
    <module>../sm.enterpriseSchemas</module>
    <module>../sm.jmsEsb</module>
    <module>../ee.entEvent.eventMsg.vendorNetcool</module>
    <module>../ee.entEvent.eventMsg.vendorNetcool.application</module>-->
  </modules>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.7.1</version>
   
      </plugin>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-ear-plugin</artifactId>
      <version>3.1.0</version>
      <configuration>
        <finalName>ee.entEvent.eventMsg.vendorNetcool.application</finalName>
        <version>6</version>
        <defaultLibBundleDir>lib</defaultLibBundleDir>
        <modules>
            <module>../sm.baseSchemas</module> 
            <module>../sm.cleClient</module>
            <module>../sm.enterpriseSchemas</module>
            <module>../sm.jmsEsb</module>
            <module>../ee.entEvent.eventMsg.vendorNetcool</module>
            <module>../ee.entEvent.eventMsg.vendorNetcool.application</module>-->
        </modules>
          <!-- Add your project modules here -->
          <ejbModule>
            <groupId>com.tibco.bw</groupId>
            <artifactId>ee.entEvent.eventMsg.vendorNetcool.application.parent</artifactId>
            <bundleFileName>my-ejb-module.jar</bundleFileName>
          </ejbModule>
          <webModule>
            <groupId>com.tibco.bw</groupId>
            <artifactId>ee.entEvent.eventMsg.vendorNetcool.application.parent</artifactId>
            <contextRoot>/my-web-module</contextRoot>
          </webModule>
          <!-- Add more modules as needed -->
        <modules>
            <module>../sm.baseSchemas</module> 
            <module>../sm.cleClient</module>
            <module>../sm.enterpriseSchemas</module>
            <module>../sm.jmsEsb</module>
            <module>../ee.entEvent.eventMsg.vendorNetcool</module>
            <module>../ee.entEvent.eventMsg.vendorNetcool.application</module>-->
        </modules>
      </configuration>
    </plugin>
    </plugins>
  </build>
    <dependencies>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>sm.baseSchemas</artifactId>
         <version>1.0.0</version>
    </dependency>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>sm.cleClient</artifactId>
         <version>1.0.0</version>
    </dependency>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>sm.enterpriseSchemas</artifactId>
         <version>1.0.0</version>
    </dependency>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>sm.jmsEsb</artifactId>
         <version>1.0.0</version>
    </dependency>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>pp.customXpathFunctions</artifactId>
         <version>1.0.0</version>
    </dependency>
      </dependencies> 
</project>

执行mvn clean install命令后日志显示构建成功,但.ear文件未生成;执行mvn clean package的日志如下:

C:\Users\ndey\Downloads\ee.entEvent.eventMsg.vendorNetcool-dev\ee.entEvent.eventMsg.vendorNetcool-dev\src\ee.entEvent.eventMsg.vendorNetcool.application.parent>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] --< com.tibco.bw:ee.entEvent.eventMsg.vendorNetcool.application.parent >--
[INFO] Building ee.entEvent.eventMsg.vendorNetcool.application.parent 1.0.0-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ ee.entEvent.eventMsg.vendorNetcool.application.parent ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.289 s
[INFO] Finished at: 2023-05-28T09:02:14+05:30
[INFO] ------------------------------------------------------------------------

本地已安装Maven,日志无报错信息,但target目录未生成预期的.ear文件。

问题根源分析

pom.xml存在多处配置错误,导致EAR包无法生成:

  1. 打包类型错误:当前配置<packaging>pom</packaging>,pom类型项目是父项目,仅用于聚合子模块,不会生成任何可执行包,需要改为<packaging>ear</packaging>。
  2. ear插件配置语法错误:
    • 注释格式错误:</module>-->这种写法破坏了XML结构,导致插件配置无法被Maven正确解析。
    • 重复定义<modules>节点:ear插件的<configuration>中重复出现<modules>,且直接使用相对路径的<module>标签不符合ear插件规范,应该用<ejbModule>、<webModule>等标签指定具体模块类型。
    • 模块引用错误:错误地将当前父项目作为ejbModule和webModule的artifactId,实际应该引用对应的子模块。
  3. 子模块未启用:<modules>节点中的所有子模块都被注释,Maven不会构建依赖的子模块,即使ear插件配置正确也没有内容可打包。

修复后的pom.xml示例

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.tibco.bw</groupId>
  <artifactId>ee.entEvent.eventMsg.vendorNetcool.application.parent</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <!-- 修改打包类型为ear -->
  <packaging>ear</packaging>
  
  <!-- 启用子模块,确保Maven构建所有依赖模块 -->
  <modules>
    <module>../sm.baseSchemas</module> 
    <module>../sm.cleClient</module>
    <module>../sm.enterpriseSchemas</module>
    <module>../sm.jmsEsb</module>
    <module>../ee.entEvent.eventMsg.vendorNetcool</module>
    <module>../ee.entEvent.eventMsg.vendorNetcool.application</module>
  </modules>
  
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.7.1</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <finalName>ee.entEvent.eventMsg.vendorNetcool.application</finalName>
          <version>6</version>
          <defaultLibBundleDir>lib</defaultLibBundleDir>
          <!-- 正确配置ear模块,根据子模块实际类型选择ejbModule/webModule等 -->
          <modules>
            <!-- 示例:假设sm.cleClient是ejb模块,ee.entEvent.eventMsg.vendorNetcool.application是web模块 -->
            <ejbModule>
              <groupId>com.tibco.bw</groupId>
              <artifactId>sm.cleClient</artifactId>
            </ejbModule>
            <webModule>
              <groupId>com.tibco.bw</groupId>
              <artifactId>ee.entEvent.eventMsg.vendorNetcool.application</artifactId>
              <contextRoot>/vendorNetcool-app</contextRoot>
            </webModule>
            <!-- 根据实际模块类型添加其他模块 -->
          </modules>
        </configuration>
      </plugin>
    </plugins>
  </build>
  
  <dependencies>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>sm.baseSchemas</artifactId>
         <version>1.0.0</version>
    </dependency>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>sm.cleClient</artifactId>
         <version>1.0.0</version>
    </dependency>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>sm.enterpriseSchemas</artifactId>
         <version>1.0.0</version>
    </dependency>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>sm.jmsEsb</artifactId>
         <version>1.0.0</version>
    </dependency>
    <dependency> 
         <groupId>com.tibco.bw</groupId>
         <artifactId>pp.customXpathFunctions</artifactId>
         <version>1.0.0</version>
    </dependency>
  </dependencies> 
</project>

验证步骤

  1. 确认所有子模块的pom.xml配置正确,打包类型符合模块实际类型(如ejb、war等)。
  2. 执行mvn clean package命令,等待构建完成。
  3. 检查当前项目的target目录,确认是否生成了预期的.ear文件。

内容的提问来源于stack exchange,提问作者Niladri Dey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 08:47:03