Digital Transformation

Maven and WebSphere Web Applications (Part 2)

The parent project of the multiple module web application uses the uses the <packaging>pom</packaging> tag and several <module> tags to indicate that it is controlling the build order of several artifacts. The control is provided through the reactor plugin.

The file structure that I use is:


The ear directory is empty  (except for pom.xml). The application.xml required for an EAR is generated by the was6 maven plugin. The directory structure of the web directory is not shown here but specified as the maven standard directory layout.

There are several fields in the various hidden control structures that must be internally consistent for the build and deploy to work. This is why I prefer to use a maven archetype (created yourself for your project team) project to generate web application projects from scratch. My experience in the field indicates that developers who copy and paste from existing projects often make mistakes which are very hard to diagnose.

These are the items that you need to address:

  • Provide unique namespace (groupId + artifactId) for ear and war modules that is predictable. I solve this by using parent groupId appended with .war or .ear for the child projects.
  • Ensure the parent/child relationship of the three pom.xml files through dependencies and parent references including the correct generated ids.
  • Ensure ibm-web-ext.xml and ibm-web-bnd.xml are included in the web module.
  • Ensure the .project and .classpath files include the correct RAD facets and library definitions for a maven project.
  • Ensure the parent pom.xml has a parent reference to a project that defines the required WAS dependencies (for proper compilation).
The pom.xml file of the ear module contains two non-standard entries. The first entry ensures the associated web module is included:
The second entry binds the was6 maven plugin to the pre-integration-test phase of the maven lifecyle. This step causes the project to be deployed on your taget WebSphere Application Server based some properties listed here (and some included through build profiles):
The additional build profile properties I referred to above are machine specific settings:

You specify text values for each of the properties above that make sense on your machine. Note that was6.server and was6.targetServer will actually be the same value. You include them both because different goals of the was6 plugin used different parameter names to express the same logical value. Sometimes open source will contain idiosyncratic annoyances (but hey, you can’t beat the price!)

In the next post I will examine how the web module is processed when you are creating a portal theme or skin.

About the Author

More from this Author

Thoughts on “Maven and WebSphere Web Applications (Part 2)”

  1. Kevin, congratulations for your post!
    Please, help me…
    How use maven for ear and war for websphere portal 7?


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up