Tuesday, October 31, 2006

How to package an application into a ear file

This is for those who want to know the ideal and most common way an application is packaged in the form of an ear file. Here's how the application structure will look like:

myApp.ear
|
|--------- META-INF
| |
| |---------- application.xml
|
|--------- myEJB.jar
| |
| |--------- META-INF
| | |
| | |-------- ejb-jar.xml
| |
| |------ org
| | |----- myApp
| | |------- ejb
| |-------- *.class
|
|---------- myWeb.war
| |
| |----- WEB-INF
| |------ web.xml
| |
| |------ jsp
| |---- *.jsp
|
|---------- commonUtil.jar
|
|--------- org
|----- myApp
|------ common
|----- *.class


The application.xml present in the META-INF folder of the ear will contain the following:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>helloworld</display-name>

<module>
<java>commonUtil.jar</java>
</module>

<module>
<web>
<web-uri>myWeb.war</web-uri>
<context-root>/myWeb</context-root>
</web>
</module>

<module>
<ejb>myEJB.jar</ejb>
</module>

</application>


4 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Jaime Hablutzel said...

Interesting, but I have one question, do you know if popular IDEs like Eclipse or IntelliJ IDEA have support to deploy an ear in exploded fashion to avoid the innecesary packaging for development time?

Jaikiran said...

@SkaRootz, if the IDE is integrated with the application server specific plugins, then yes they do allow exploded deployments. For example, JBoss Tools http://www.jboss.org/tools which is a Eclipse plugin does allow exploded deployment.