Create Enterprise Application project Eclipse

Create Enterprise Application project Eclipse

Enterprise Application project bind one or more Java EE modules together which can include web module, client module, JPA module, JAR files, EJB module, connector module etc… Enterprise application deploys in the form of EAR also it’s refer as EAR project. EAR project mapped many J2EE project together and its mapping information stored in the metadata files which is called application.xml file. Please follow below steps to crate EAR project in eclipse:

Note: For this demo I will use JBoss Application Server (Version: 5.1.0) community version and Eclipse Kepler (IDE)

  • To create Enterprise Application project first we will create its module and finally pack all module inside Enterprise application project:

For this demo we well create web module using Spring MVC which will be simple hello world project and to make this enterprise we will use another project as dependency name: Java project(Jar project) and will one of its call in spring controller and get data from here.

  • First create Spring MVC project name: SpringMVCProject and to create this project in eclipse click File –> New –> Other –> Web –> Dynamic Web Project and give name SpringMVCProject.
    Final project structure:

Create Enterprise Application project Eclipse

  • To keep this tutorial short I will not show all class and XML file details based on project structure above please download this project below and copy all files/folder in it:

download Download Project: SpringMVCProject

  • Next create Java Project name: Java Project. To create click File –> New -> Other –> Java –> Java Project and give name: Java Project.
  • Final Java project structure:

Create Enterprise Application project Eclipse

 

download Download Project: JavaProject

  • Now creation of module for this demo is complete and just to show you how SpringMVCProject is dependent on JavaProject. Open SpringMVCController.java you will see below as I am showing through diagram:

Create Enterprise Application project Eclipse

  • As you could see above SpringMVCController.java is calling calling static method of another project which is separate java project.
  • Now let create EnterpriseApplicationProject. To create click File –> New –> Other –> Java EE –> Enterprise Application project as below:

Create Enterprise Application project Eclipse

  • Click next and enter as below then click Finish:

Create Enterprise Application project Eclipse

  • Our final Enterprise Application project structure:

Create Enterprise Application project Eclipse

  • Please have a look application.xml file to see how modules are included :
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" id="Application_ID" version="5">
  <display-name>EnterpriseApplicationProject</display-name>
  <module>
    <web>
      <web-uri>SpringMVCProject.war</web-uri>
      <context-root>SpringMVCProject</context-root>
    </web>
  </module>
</application>

download Download Project: EnterpriseApplicationProject

There are many ways you could run this project here I will show you two ways to run it:

  • Create EAR file and copy to JBoss deploy folder:To create EAR File right click project –> Export –> EAR file then choose location of your choice:

2014-12-12 13_16_54-Java EE - JavaProject_src_com_javahonk_EnterpriseTestClass.java - Eclipse

 

  • Once EAR file got crated copy this file to JBoss deploy folder (Location: jboss-5.1.0.GA\server\default\deploy) the start the server user below URL to open the web page:

Create Enterprise Application project Eclipse

 

Now to validate if call goes to SpringMVCController and we get response or not please use below:

Create Enterprise Application project Eclipse

  • Second way to run EAR project: Configure JBoss server to eclipse (If you are not sure how to do it please use this tutorial) and to run –> right click EnterpriseApplicationProject  –> Run As –> Run on Server you will see JBoss will deploy application as EAR. To validate the deployment please use same URL as above you will see same output.
  • That’s it. For more information about create enterprise application project please refer this link

Leave a Reply

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