Thursday, January 19, 2006

HTML Reference

I like this site as an HTML reference:

Wednesday, January 04, 2006

Creating an ear, in the simplest way

I don't know how many times I've wanted to test something simple in an ear, but wanted to avoid the complexities of the application I'm working on, or the container I'm working in. I end up having to remind myself what are the basic requirements for creating an ear. That often takes a while, since in a normal working environment, you create the ear and forget about it.

So, I created a very simple ear here, and deployed it in JBoss. It has only four files: a build file, an application configuration, a web configuration, and a jsp. Here are the steps I followed:
  1. Installed JBoss Application Server. I installed version 4.0.3 SP1, available here: It's an executable jar, and I did a complete install, and accepted all the defaults.
  2. Created a new project in my IDE. My project has the following top-level directories:
    • bin/ -- for the build file
    • conf/ -- for application configuration, in this case just application.xml
    • testWar/ -- a basic web application
  3. Created a META-INF/ directory in conf/, and inside put an application.xml file (see below). All that this file does is configure the web-app at the context root /testEar.
  4. Created a web/jsp/ directory in testWar/, and inside put a hello.jsp file (see below).
  5. Created a WEB-INF/ directory in testWar/, and inside put a web.xml file (see below). All this file does is configure hello.jsp as the welcome page.
  6. Created a build.xml file in bin/ (see below).
  7. Ran the ant build (in the bin directory, ran "ant build". (I assume a JDK and ant are installed).
  8. Copied the resulting ear (testEar.ear) into the JBoss deployment directory (in my installation, this is in jboss-4.0.3SP1/server/default/deploy).
  9. Started JBoss (in my installation, I ran jboss-4.0.3SP1/bin/run.bat).
  10. Pointed my browser to http://localhost:8080/testEar.
Here is application.xml:
<application xmlns=""
<description>Test Ear</description>
<display-name>Test Ear</display-name>

Here is hello.jsp:

Hello, World

Here is web.xml:
<web-app xmlns=""

Here is build.xml:

<project name="testEar" default="build">

<property name="project.root.dir" value=".."/>
<property name="conf.dir" value="${project.root.dir}/conf"/>
<property name="test.war.dir" value="${project.root.dir}/testWar"/>

<target name="build">
<war destfile="testWar.war" webxml="${test.war.dir}/WEB-INF/web.xml">
<fileset dir="${test.war.dir}/web"/>
<ear destfile="testEar.ear" appxml="${conf.dir}/META-INF/application.xml">
<fileset dir="." includes="*.war"/>