How to create a modularized ear project in maven
Tech-Today

How to create a modularized ear project in maven


This post is one way of creating a typical javaee6 maven project that contains ear, web, ejb and api. The output of course is an ear file that contains (web, ejb and api).

How it looks like (assuming our top project is named ipiel):
+ipiel
 +ipiel-ear
 +ipiel-web
 +ipiel-api
 +ipiel-ejb

*Note that ipiel, can also be a child of a another project, which could be a main project where ipiel is just a component.

How to create the 5 listed maven projects above (I'm assuming you have eclipse with maven plugin installed):
1.) ipiel (the main pom project)
  a.) In eclipse create a new maven project, skip archetype selection so it will only create a maven project that has a src folder no main/test.
  b.) groupId=com.ipiel
       artifactId=ipiel
       packaging=pom
       version=leave the default

2.) ipiel-api (where interface is declared that is shared between ejb and web)
  a.) Right click the ipiel project and select new->maven module
  b.) Since this will contain java files, select maven-archetype-quickstart, you can filter "quickstart"
  c.) groupId=com.ipiel
       artifactId=ipiel-api
       packaging=jar
       version=leave the default
  d.) Create a class Bird and add a method fly.

3.) ipiel-ejb (the backing/manage bean)
  a.) Right click the ipiel project and select new->maven module
  b.) Since this will contain java files, select maven-archetype-quickstart, you can filter "quickstart"

  c.) groupId=com.ipiel
       artifactId=ipiel-ejb
       packaging=ejb
       version=leave the default
  d.) Add dependency to ipiel-api, and implement the Bird interface, in a class let's say Eagle.
<dependency>
<groupId>com.ipiel</groupId>
<artifactId>ipiel-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

4.) ipiel-web (the ui project, where you define your xhtml files)
  a.) Right click the ipiel project and select new->maven module
  b.) In the maven filter enter "web" and select org.codehaus.mojo.archetypes webapp-javaee6.
       It's a simple web archetype and we need to add some files to it.
    1.) Add a new source folder /src/main/resources.
    2.) Inside /src/main/resources create 2 folders /META-INF and /WEB-INF
    3.) Normally we have beans.xml and web.xml inside /WEB-INF folder and /META-INF contains MANIFEST.MF
  c.) groupId=com.ipiel
       artifactId=ipiel-web
       packaging=war
       version=leave the default
  d.) Make sure that you add maven-war-plugin in pom.xml.
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<!-- In version 2.1-alpha-1, this was incorrectly named warSourceExcludes -->
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
  e.) The web project is also dependent on ipiel-api, since it needs to call it's backing bean from the ipiel-ejb project.

5.) ipiel-config (where I normally place persistence and resource files)
  a.) groupId=com.ipiel
       artifactId=ipiel-config
       packaging=pom
       version=leave the default
  b.) Create a new maven module, and select maven-archetype-quickstart, you can filter "quickstart"
I defined where my resources are in this project:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

6.) ipiel-ear (the output project)
  a.) Create a new maven module project, skip archetype selection, so we have a basic maven project
  b.) groupId=com.ipiel
       artifactId=ipiel-ear
       packaging=ear
       version=leave the default
  c.) 




- Create A Simple Javaee6 Web App With Maven, Glassfish And Postgresql
This tutorial creates a simple javaee6 project using eclipse with maven. The application has 1 xhtml page that has a create button, and as you guest it when press will create an Employee record in the database. We use postgresql as the database and glassfish...

- How To Setup Findbugs With Maven On Eclipse
Before you proceed with this exercise, it's required to check my blog on how to create a modular maven project. http://czetsuya-tech.blogspot.com/2012/04/how-to-create-modularized-maven-project.html 1.) In this link you will...

- How To Create A Modularized Maven Project In Eclipse
I've just noticed that it's easier to do this now on eclipse-jee-indigo, no need to use the console :-) I'll try to make this write up short, but I guess it will not be. So first, you should have the ff installed (if you don't know how...

- Dns That You Could Choose From In The Philippines
Below are the DNS I'm using in the Philippines. The last is specifically for Globe network. OpenDNS - fast but restrictive    208.67.222.222    208.67.220.220 Cisco - ok for me    64.102.255.44    128.107.241.185...

- How To Access Asp:textbox With Runat=server Attribute In Javascript
For example you have a textbox which has a default value, and you want to clear that value when the user click on the textbox: <asp:TextBox ID="txtBox" runat="server" onclick="clear()" Text="Enter Keyword" /> <script type="text/javascript">...



Tech-Today








.