Question

We have 12 ear files in our SOA layer, we deploy these EARs individually to JBoss. Increasingly we are having trouble managing the dependencies, and the deployment of all these EAR files.

Each EAR is:

  1. built using Maven, and the maven-ear-plugin
  2. contains a webModule for RESTful access like payment-rs/payment
  3. has an API like payment-api-1.1.9.jar, which is often a dependency to other EARs
  4. uses maven version numbers like payment-service-1.1.9.ear

Ideally, we could have a single EAR (or some other format) that we could version and certify together. I've tried adding modules to the parent pom, but that just facilitates building all the individual EAR at the same time.

Is there a way to somehow combine these EAR files?

If the answer is no, any ideas on if we are "doing it wrong" with our architecture? Should we combine the projects? Solve the API dependency issues some other way?

Was it helpful?

Solution

To me it sounds like you should go for single ear with multiple web modules. See the official docs: http://maven.apache.org/plugins/maven-ear-plugin/modules.html

As you would still use SOA the web services could communicate between each other via whatever interface defined, just deployment could be simplified dramatically.

Your project pom.xmls could look like this:

WebModuleA with pom.xml like:

<groupId>???</groupId>
<artifactId>webModuleA</artifactId>
<version>???</version>
<type>war</type>

<dependencies>
  <dependency>
    <groupId>???</groupId>
    <artifactId>payment-service</artifactId>
    <version>1.1.9</version>
    <type>jar</type>
  </dependency>
...

webModuleB with pom.xml like:

<groupId>???</groupId>
<artifactId>webModuleB</artifactId>
<version>???</version>
<type>war</type>

<dependencies>
  <dependency>
    <groupId>???</groupId>
    <artifactId>payment-service</artifactId>
    <version>1.1.9</version>
    <type>jar</type>
  </dependency>
...

payment-service with pom.xml like:

<groupId>???</groupId>
<artifactId>payment-service</artifactId>
<version>1.1.9</version>
<type>jar</type>
...

and finally, the earModule that would contain all the web modules:

<groupId>???</groupId>
<artifactId>earModule</artifactId>
<version>???</version>
<type>ear</type>

<dependencies>
  <dependency>
    <groupId>???</groupId>
    <artifactId>webModuleA</artifactId>
    <version>???</version>
    <type>war</type>
  </dependency>
  <dependency>
    <groupId>???</groupId>
    <artifactId>webModuleB</artifactId>
    <version>???</version>
    <type>war</type>
  </dependency>
...

<plugin>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.8</version>
    <configuration>
      <modules>
        <webModule>
          <groupId>???</groupId>
          <artifactId>webModuleA</artifactId>
        </webModule>
        <webModule>
          <groupId>???</groupId>
          <artifactId>webModuleA</artifactId>
        </webModule>
    ...
      </modules>
    </configuration>
  </plugin> 

That should be basically it.

Moreover, if you want to prevent having payment-service packaged in the each war webModuleX (to reduce the size of the final ear archive), make sure to go for so called "skinny wars": http://maven.apache.org/plugins/maven-ear-plugin/examples/skinny-wars.html

Feel free to ask in detail, if some of the suggestions is unclear or inaccurate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top