Create Maven EAR Project Eclipse

Create Maven EAR Project Eclipse

In this demo you will see how to create EAR (Enterprise Archive) project in eclipse. EAR is a Java EE standard format use to package one or more module into a single module so that we can deploy many module as single archive module on application server.

EAR file contains main XML files called deployment descriptors which says how many module package together and deploy on the application server. EAR file is generally a standard zip file (JAR File) with .ear extension. One or more entries inside deployment descriptor which represent module of the application puts inside meta data directory called META-INF.

We will use Eclipse Kepler to create EAR project. Here we will create two module JAR and WAR and include inside EAR module and all module will be created inside parent module. Please follow steps below:

  • Final project structure:

Create Maven EAR Project Eclipse

  • Create parent module: JavaHonkParent
  • Click File –> New –> Other –> Maven –> Maven Project then click Next

Create Maven EAR Project Eclipse

  • On next window choose as given below then click next:

Create Maven EAR Project Eclipse

  • Fill out input field as given below then click finish. This will create parent project name: JavaHonkParent:

Create Maven EAR Project Eclipse

  • Now add new JAR module to parent : JavaHonkJARModule. Right click JavaHonkParent –> New –> Other –> Maven Module –> Next
  • Give module name as below then click next:

Create Maven EAR Project Eclipse

  • Choose archetype quick start then click next:

Create Maven EAR Project Eclipse

  • Fill out field as below then click finish. This will create new JAR module name: JavaHonkJARModule:

Create Maven EAR Project Eclipse

  •  Now create WAR module. To create right click parent module JavaHonkParent –> New –> Other –> Maven –> Maven module –> Next
  • Fill out fields as below:

Create Maven EAR Project Eclipse

  • Next choose archetype webapp then click next:

Create Maven EAR Project Eclipse

  • Please enter information as below then click finish. This will create WAR module name: JavaHonkWARModule

Create Maven EAR Project Eclipse

  • Finally now let’s create EAR module. Right click parent module JavaHonkParent –> New –> Other –> Maven –> Maven Module –> Next
  • Enter name and choose create a simple project check box as below then click next:

Create Maven EAR Project Eclipse

  • Type packaging type ear then click finish as below:

Create Maven EAR Project Eclipse

  • Now we have to add both JAR and WAR dependencies to EAR module. To add dependencies open pom.xml from EAR module and add dependencies as below:

Create Maven EAR Project Eclipse Create Maven EAR Project Eclipse

  • As you see we have added JAR and WAR dependencies in EAR module. Don’t forget to save pom.xml file:

Create Maven EAR Project Eclipse

  • To print sample message on web page please open index.jsp from WAR module and include below:

Create Maven EAR Project Eclipse

  • Next start build process for all modules. As you have seen all our module EAR, WAR and JAR are added inside parent module so if we run mvn install from parent then this will create JAR, WAR and include inside EAR file. To build right click JavaHonkParent –> Run As –> Maven Install

Create Maven EAR Project Eclipse

  • Once you see build successful message on console then refresh and check all individual module. You will see JAR, WAR and EAR got created as below:

Create Maven EAR Project Eclipse

  • Maven install also create application.xml files please double click to open and see module and context URL. Finally we are ready to deploy this EAR on JBoss server.

Create Maven EAR Project Eclipse

  • Now to deploy ear on JBoss server please copy ear file to JBoss (jboss-6.1.0.Final\server\default\deploy) folder and start the server and check in log file or console if ear deployed or not. Search below context if you see means it deployed successfully:

Create Maven EAR Project Eclipse

  • Enter below URL in browser you will see below:

Create Maven EAR Project Eclipse

  • That’s it. We have created maven EAR project and deployed successfully on JBoss server.
  • For more information about EAR project please visit this link

10 thoughts on “Create Maven EAR Project Eclipse

Leave a Reply

Your email address will not be published. Required fields are marked *