Create Ant EAR Project Eclipse
EAR project in java binds one or more Java Enterprise Edison modules. Together this includes web module, JAR files, client module, JPA module, EJB module, connector module etc…EAR application deploys in the form of archive ear. EAR project mapped many Java EE project together and mapping information are stored in metadata files that is called application.xml file. Please follow below steps to crate EAR project and deploy on JBoss server:
Note: We will use Eclipse Kepler to create project because this version comes with maven plug-in. You could also use any version of Eclipse which comes with maven plug-in or install in eclipse if not available.
Final project structure:
- Create dynamic web project. To create click File –> New –> Other –> Web –> Dynamic Web Project. Give project name: JavaHonkAntWAR
- Add index.jsp inside WebContent folder below to print successful message on console after deployment.
- Create java project. Click File –> New –> Other –> Java –> Java Project name: JavaHonkAntJAR
- Now create EAR project and include two project JAR and WAR in it. Click File –> New –> Other –> Java EE –> Enterprise Application Project and add as below:
- Now enterprise application got created. We could run directly in eclipse with Jboss server. If you are not sure how to configure and run Jboss in eclipse please use this tutorial. To run EAR project right click JavaHonkAntEAR –> Run As –> Run on Server. You will below successful message on web page:
Now to run through ant build file please copy and paste below build.xml
- Copy below build.xml to JavaHonkAntJAR project:
- Copy below build.xml to JavaHonkAntWAR project:
- Copy below build.xml to JavaHonkAntEAR project:
- Note: Please don’t forget to change directory path of Jboss and workspace in build.xml file.
- Now right click main build.xml file from JavaHonkAntEAR project –> Run As –> Ant Build. This will call both JAR and WAR build then will make EAR file and deploy to the JBoss deploy folder.
- To verify please go to Jboss deploy folder and check if ( Jboss-6.1.0.Final\server\default\deploy) JavaHonkAntEAR.ear copied or not. Now start JBoss server using jboss-6.1.0.Final\bin\run.bat file check on console below:
- Once your deployment is complete please use below URL in your browser there you will below response:
- That’s it. For more information about create EAR project please visit this link