In This Article:

Based in an integration of best-of-breed open source technologies, and with a vibrant and thriving community backing a certified open source server, Geronimo is set to take the enterprise market by storm. This article will introduce you to Geronimo and give you the basics you need for developing and deploying a simple Java EE web application on Geronimo.

Why Geronimo?

Geronimo is not the only open source app server available in the market. There are other open source Java EE app servers out there as well, such as JOnAS from ObjectWeb. However, Geronimo fills a need that other application servers do not. With Geronimo, components can be easily integrated. Its key aim is to support custom builds, geared to the needs of specific applications. Geronimo offers choices. For instance, if you don't want transaction management, you can go for a web-tier container such as Tomcat or Jetty. Geronimo supports the assembly of custom components pretty easily. In short, you can make it whatever you need it to be. This means Geronimo is much more than simply an app server; it offers a framework that can be used to glue together different components.

Geronimo doesn't try to reinvent the wheel, and it's not a rip-off of any of the existing open source frameworks or tools. Rather, Geronimo is an integration of several open source projects, some of which are shown below:

One of the most elegant features of Geronimo is that it doesn't require a restart. Unlike other web- and business-tier containers, which require restarting the container for any configuration change, Geronimo is tailored from the ground up to support dynamic class loading, and keeps running as an uninterrupted service.

A Look Under the Hood

Geronimo is a loose integration of components called Geronimo Beans or simply GBeans. GBeans, which are the building blocks of Geronimo, are managed beans based around an IoC container concept, and they're used to add services to the Geronimo kernel. Almost everything in Geronimo is a GBean.

It's easy to extend Geronimo by deploying new GBeans. GBeans define the capabilities of the server and are registered with the kernel as they are deployed. The GBean components follow a particular life cycle as the kernel creates them, injects dependencies, notifies events, and calls their methods. Each GBean can maintain a state, depend on other GBeans, and contain logic that defines its functionality. The GBean architecture is a Dependency Injection (DI) configuration and management system. A GBean is plugged to the kernel through a plan, which is an XML-based configuration file. Further, components can be easily removed by editing the configuration files. For more information on Geronimo GBean architecture and IoC containers, refer to the Resources section.

Get Started with Geronimo

Geronimo requires Java SE 1.4 (or higher, but earlier than SE 5). The latest milestone release available as of this writing is M5. Unzip the Geronimo with Tomcat container zip at some location, and set the GERONIMO_HOME environment variable to this location.

Start Geronimo by booting its kernel. Once started, Geronimo will load all predefined modules along with any other application modules as shown below (for brevity, not all fields are shown here):

Next, verify the Geronimo installation by accessing the Geronimo console window at http://localhost:8080/console, as shown in Figure 1 below. Use the default username (system) and password (manager). Stopping Geronimo is easy; Ctrl-C stops the app server.

Figure 1. Apache Geronimo Console

Sample Application

For an introductory article like this, we'll create a simple web application and deploy it on Geronimo. Please make sure that the following environment variables are set correctly.

Environment variable

Purpose

JAVA_HOME

Indicates the base directory of your standard Java SE installation.

GERONIMO_HOME

Set to the root directory of your Geronimo installation.

ANT_HOME

Set to the root directory of your Ant installation.

GERONIMO_DEV

Indicates the base directory of application development space.

PATH

Ensure that ANT_HOME/bin is in your PATH.

Within GERONIMO_DEV, create the following directories:

etc: All deployment plans are kept inside this directory.

src: This directory is used for placing any servlets and other Java source files.

web: All public JSP documents are placed inside this directory.

Deployment Plans

We'll need two deployment plans, namely web.xml and geronimo-web.xml. Before we dive into these, I'll clarify their differences. The following table will help differentiate between the two deployment plans and their roles.

Deployment Plan

Type

Location

Purpose

web.xml

Standard Java EE web deployment descriptor

This must be stored as part of the WAR file under the WEB-INF subdirectory.

The configId attribute specifies the name of our application, com/onjava/safari/myApp. Next, we set up the context (/myApp), which is the directory where our application is placed once deployed to Geronimo.

Build the App

Next, we'll do an incremental build with Ant. We need an Ant build file (build.xml), placed in GERONIMO_DEV. The build.xml is a well-formatted XML file that describes the build process of our application as shown below:

This creates a .war file (placed inside the /dist directory), which will be deployed inside the Tomcat container shipped with Geronimo app server.

Deploy the App

Here, we'll use Geronimo's deployer to deploy the .war file. Geronimo provides a deploy command for this purpose. You must provide an administration login (system/manager) on the command line while deploying. If not explicitly specified, the deployer will ask you for it. The following command deploys the .war file:

The deployer is smart enough to figure out the kind of component being deployed; we just give it our .war file and the deployer will deploy the file as a Web application. The deployer.jar deploys the application module based on the information provided in the deployment plan (geronimo-web.xml) to the Geronimo server.

Alternatively, you can manually deploy the .war file using Geronimo's console window (as shown in Figure 2). Select the Deploy New link from the Console Navigation panel on the left, browse to the WAR file, and then click the Install button.

Figure 2. Deploy new web app in Geronimo

Once deployed, the web app will appear under the "Installed Web Applications" listing in Geronimo's console window as shown below in Figure 3.

Figure 3. Installed Web Applications

Test the App

All that said, let's cheerily run through it. Start up a browser and try the URL http://localhost:8080/myApp/hello.jsp. The Tomcat web container processes and executes the JSP as shown in Figure 4 below:

Figure 4. Test JSP running on Geronimo app server

Conclusion

Geronimo is modular by nature. This allows easy plugging of modules such as Apache Derby, which ships with Geronimo. Integration of frameworks like Spring is seamless. So, what's holding you up? It's time to give Geronimo a spin.