Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appname.ear.xml contains duplicate targetArchive #397

Open
e30532 opened this issue May 28, 2020 · 4 comments
Open

appname.ear.xml contains duplicate targetArchive #397

e30532 opened this issue May 28, 2020 · 4 comments

Comments

@e30532
Copy link

e30532 commented May 28, 2020

Problem: If maven-ear-plugin builds an EAR which contains two web modules derived from a single web module project and we deploy the EAR to Liberty through WDT, only one of the web modules is started.

  1. create a maven project.
    image

image

image

  1. add a maven module (ear)

image

image

image

  1. add a maven module (war)

image

image

image

  1. set pom.xml
pom.xml of test-war.
------------------------------
<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>
  <parent>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>test-war</groupId>
  <artifactId>test-war</artifactId>
  <packaging>war</packaging>
  <name>test-war</name>
 
  <dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.3</version>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
------------------------------

pom.xml of test-ear
------------------------------
<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>
  <parent>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>test-ear</groupId>
  <artifactId>test-ear</artifactId>
  <packaging>ear</packaging>
  <name>test-ear</name>
 
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <configuration>
          <modules>
            <webModule>
              <groupId>test-war</groupId>
              <artifactId>test-war</artifactId>
              <bundleFileName>test-war-1.war</bundleFileName>
              <contextRoot>/test-war-1</contextRoot>
            </webModule>
            <webModule>
              <groupId>test-war</groupId>
              <artifactId>test-war</artifactId>
              <bundleFileName>test-war-2.war</bundleFileName>
              <contextRoot>/test-war-2</contextRoot>
            </webModule>
          </modules>
        </configuration>
      </plugin>
    </plugins>
  </build>
 
  <dependencies>
    <dependency>
      <groupId>test-war</groupId>
      <artifactId>test-war</artifactId>
      <version>${project.version}</version>
      <type>war</type>
   </dependency>
  </dependencies>

</project>
------------------------------


pom.xml of test
------------------------------
<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>test</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>test</name>
  <modules>
      <module>test-ear</module>
      <module>test-war</module>
  </modules>
</project>

------------------------------
  1. maven install

image

  1. select "Run applications directly from the workspace"

image

  1. only test-war-1 becomes available.
    [ERROR ] CWWKZ0117E: Application test-ear failed to locate module test-war-2.war of type web
    [AUDIT ] CWWKT0016I: Web application available (default_host): http://localhost:9080/test-war-1/
    [AUDIT ] CWWKZ0001I: Application test-ear started in 0.121 seconds.

  2. appname.ear.xml contains duplicate targetArchive. <-- this is the issue.

image

image

  1. Even if we uncheck "Run applications directly from the workspace", only one web module becomes available. <-- this is also an issue.

image

  1. If we export the ear and put it under dropins, both of the war modules become available.

[AUDIT ] CWWKT0016I: Web application available (default_host): http://localhost:9080/test-war-1/
[AUDIT ] CWWKT0016I: Web application available (default_host): http://localhost:9080/test-war-2/

  1. If we export the ear and put it under apps, both of the war modules become available.

[AUDIT ] CWWKT0016I: Web application available (default_host): http://localhost:9080/test-war-1/
[AUDIT ] CWWKT0016I: Web application available (default_host): http://localhost:9080/test-war-2/

So the problem is happening only when we deploy the application through WDT.

@josephca
Copy link
Contributor

josephca commented Jun 1, 2020

Related to

// Handles archives in archives such as a war in an ear. Will generate

@josephca
Copy link
Contributor

It seems

result = runtimePath.append(ref.getArchiveName()).makeAbsolute().toString();
returns the first found.
ref.getArchiveName() may need to be checked when returning the result.

@eharris369
Copy link
Contributor

eharris369 commented Jul 13, 2020

The org.eclipse.wst.common.component file in the .settings for the ear has:

<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="test-ear-0.0.1-SNAPSHOT">
        <wb-resource deploy-path="/" source-path="/target/m2e-wtp/ear-resources"/>
        <wb-resource deploy-path="/" source-path="/src/main/application" tag="defaultRootSource"/>
        <dependent-module archiveName="test-war-1.war" deploy-path="/" handle="module:/resource/test-war/test-war">
            <dependency-type>uses</dependency-type>
        </dependent-module>
        <dependent-module archiveName="test-war-2.war" deploy-path="/" handle="module:/resource/test-war/test-war">
            <dependency-type>uses</dependency-type>
        </dependent-module>
    </wb-module>
</project-modules>

But the Module objects don't appear to have this information. In fact the exact same Module is just passed in twice on the publishModules call. The ids are the same:

image

@josephca
Copy link
Contributor

Opened a bugzilla bug against 'org.eclipse.wst.common.component'
https://bugs.eclipse.org/bugs/show_bug.cgi?id=565218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants