Search code examples
javamavenwebsphereear

Maven packaging for websphere


I am trying to build an EAR file - Which can be deployed in IBM websphere server. This is an existing struts appliation, i am trying to mavenize it. This project contains two folders

   1. web
   2. webEAR

web is actually for war file and webEAR folder for the EAR file, web contains all the code, and webEAR is a kind of a wrapper.

Steps I have already done are below

  1. IDE - Eclipse
  2. Java version - 1.7
  3. Convereted both web and webEAR to Maven - (Configure to Maven)
  4. edited the POM.XML like below

<modelVersion>4.0.0</modelVersion>
	<groupId>com.comp.web</groupId>
	<artifactId>web</artifactId>
	<version>0.0.1</version>
	<packaging>war</packaging>
	<name>WEB</name>
	<description>WEB</description>

added all relevant jar files - which are in lib folder as below (sample)

<dependency>
	<groupId>jarfile</groupId>
    <artifactId>com.ibm.jar</artifactId>
    <version>1.0</version>
    <scope>system</scope>	 
<systemPath>${basedir}/WebContent/WEBINF/lib/com.ibm.jarfile.jar</systemPat>
	</dependency>

Now i dont have any errors in the eclipse, and I can run the application by right clicking the webEAR folder -> Run in Server, It works.

but I am not sure, how to create a EAR file , which has the war file, so that I can deploy in the WAS server dev environment.

Can someone show me a way I can do this. currently there is no POM.xml in the webEAR maven folder

P.S - I am not a Java developer. This is a first maven related project I am assigned to. I appreciate any help


Solution

  • Your module should have <packaging>ear</packaging>.

    In the dependencies for this ear module ( Use a new module to build the ear ) include your war module as below.

    <dependency>
        <groupId>com.comp.webGroupId</groupId>
        <artifactId>war-artifact</artifactId>
        <version> war-version</version>
        <type>war</type>
    </dependency>
    

    In the build plugins for this ear module include the maven-ear-plugin.

    <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
            <finalName>web</finalName>
            <version>versionNumber</version>
            <generatedDescriptorLocation>${basedir}/src/main/application/META-INF</generatedDescriptorLocation>
            <modules>
                <webModule>
                    <groupId>com.comp.webGroupId</groupId>
                    <artifactId>war-artifact</artifactId>
                    <uri>web.war</uri>
                    <bundleFileName>web.war</bundleFileName>
                    <contextRoot>/applicationName</contextRoot>
                </webModule>
            </modules>
        </configuration>
    </plugin>
    

    Add any specific configuration values as required.