Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

A first look at Apache Geronimo

Start developing and deploying J2EE apps on Apache's open source J2EE server

The ambitious Apache Geronimo project has been going full-steam for more than a year now and has recently made its third milestone release. If you haven't checked it out yet, this article will help you get started. We'll download and install Geronimo, review some of its architecture, and go through a couple of sample J2EE applications.

Although no date has been set for the official release, its list of stated goals is indeed impressive:

  • Pass Sun Microsystems' J2EE 1.4 certification
  • Reuse as much existing ASF (Apache Server Foundation) code as possible
  • Integrate technology outside of ASF within Geronimo, most notably OpenEJB and ActiveMQ from codehaus.org


Geronimo is a J2EE server, which means it includes all the containers required by the J2EE 1.4 specification (but, thanks to smart thinking, is backwards compatible to earlier versions). Wherever possible, Geronimo uses existing open source products. Some of these are:

  • Servlet container services: Jetty and Tomcat
  • Enterprise JavaBean container: OpenEJB
  • Java Message Service (JMS) provider: ActiveMQ
  • Database connection pooling: TranQL
  • Transaction support: HOWL (High-speed ObjectWeb Logger)
  • Database: Axion, Derby
  • Java Management Extensions (JMX) support: MX4J


Each service is implemented by a core object called a GBean. Much work went into the design of these GBeans so the core server could manage their entire lifecycles without manual intervention.

Geronimo and JBoss
Geronimo has also had to deal with some legal noise from JBoss, who alleges similarities between the Geronimo and JBoss codebases. It appears as if the ASF has successfully repudiated these allegations, but as yet, JBoss has not acquiesced. If nothing else, this situation means the project is being carefully watched by its competitors!


Build and install Geronimo

Although the Geronimo team makes milestone releases available (the current one is M3), I recommend using the latest source and building Geronimo yourself. While building from source can be time consuming, you will need the latest source to get the examples in this article to work. (I did my best to get them running on M3, but alas, they wouldn't all work.) To build Geronimo, you need three things: the Subversion version control system client, Apache Maven, and the Geronimo source code. I assume you have downloaded and installed the first two per their instructions. Now, with both the Subversion client and the Maven executable in your PATH, you can build Geronimo.

First, you need to download Geronimo. To do that, type this Subversion command:

 svn checkout http://svn.apache.org/repos/asf/geronimo/trunk geronimo



This command creates a directory called geronimo, which contains the Geronimo source code, in the directory where you are currently located. Now, change into the geronimo directory and do the build:

 cd geronimo
maven -Dmaven.test.skip=true -Dmaven.itest-skip=true m:rebuild-all 



The two system properties tell Maven to ignore all the tests and just do a straight build. While the Geronimo build instructions tell you to build without them, I couldn't get Geronimo built without some tests failing. Thankfully, however, whatever failed did not affect this article's examples.

If this is your first time executing Maven, you may have to wait a bit. On one of my Windows XP machines with an ISDN connection, execution took an hour and a half! But chances are your time will be considerably less. Still, find a good movie to watch while you wait.

Eventually, the build will complete—hopefully with success. If it showed a failure, you'll have to wait until the next day and hope whatever was broken has been fixed. Or join one of the Geronimo lists and let the team know about your problems.

In the source code tree, you will find the build files in the modules/assembly/target/geronimo-1.0-SNAPSHOT subdirectory. Rather than remembering all that, create a symbolic link somewhere convenient. In my case, I did:

 cd /build/ext
ln -s geronimo/modules/assembly/target/geronimo-1.0-SNAPSHOT geronimo-latest



>From now on, I'll refer to this Geronimo installation directory as $GERONIMO_HOME.

Create a sample Web application

Currently, Geronimo does not come with much in the way of demo or default applications. So let us start with the first of a series of sample applications we will build for this article. Find a development space somewhere (mine is in /devel/test), and create a directory called gtest. I'll refer to this directory as $GERONIMO_DEVEL. Within this directory, create the following directories:

 etc
src
web



Our first project is just a simple Web application. For this, we need three files. First, we need a simple JSP (JavaServer Pages) page, index.jsp, which we put in the web directory:

 <%@ page language="java" import="java.util.Date" %>
<html>
 <head>
  <title>Geronimo Test Application</title>
  <style type="text/css">
   <!--
    a { text-decoration: none }
    body { font-family: verdana, helvetica, sans serif; font-size: 10pt; }
    td { font-family: verdana, helvetica, sans serif; font-size: 10pt; }
    p { font-family: verdana, helvetica, sans serif; font-size: 10pt; }
    ul { font-family: verdana, helvetica, sans serif; font-size: 10pt; }
    h3 { font-family: verdana, helvetica, sans serif; font-size: 12pt; font-weight: bold; color: #547180; }
   -->
  </style>
 </head>
 
 <body>
  <br/> 
  <br/> 
  <center><h3>Geronimo Test Application</h3><br/>
  <table width="50%"><tr><td>
   <p>Welcome to Geronimo. Today is <%=(new Date())%>. This is a J2EE application running inside of Geronimo. Here are some things you can try</p>
   <ul>
    <li><a href="ejbtest.jsp">Test a simple EJB</a></li>
    <li><a href="dbtest.jsp">Test a JDBC connection pool</a></li>
   </ul>
  </td></tr></table>
  </center>
 </body>
</html>



Second, we need a Web application descriptor, web.xml, which goes in the etc directory:

 <?xml version="1.0"?>
   
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
   
<web-app id="GeronimoTestWebApp">
    <display-name>GeronimoTestWebApp</display-name>
</web-app> 



Note the id attribute in the <web-app> tag. This gives Geronimo a name for your application. (If you don't supply the name, Geronimo will try to use the value of the <display-name> tag.) Without a name—technically a configuration id—Geronimo can't deploy the application.

DTDs and XML schemas
I purposely use the Servlet 2.3 specification document type definition for my web.xml to keep things as simple as possible. Geronimo supports not only DTDs, but also the newer XML schemas as used in the J2EE 1.4 specification. As I imagine many of you have spent much of your time developing against the 1.3 specification, it is nice to know you don't have to update all your descriptor files to run on Geronimo.


Finally, we need an Ant build file. If you don't have Ant installed, you can download it from Resources. Once you install it, make sure the bin directory in the Ant installation directory is in your PATH. This is the build file we'll use. It is called build.xml and goes right in $GERONIMO_DEVEL:

 <project default="build" basedir=".">
   
  <property name="ghome" value="${user.home}/devel/build/ext/geronimo-latest"/>
   
  <path id="cp"> 
    <pathelement path="${java.class.path}"/>
    <fileset dir="${ghome}/repository/geronimo-spec/jars">
      <include name="*.jar"/>
    </fileset>
  </path>
 
  <target name="prepare">
    <mkdir dir="dist"/>
    <mkdir dir="classes"/>
    <mkdir dir="build"/>
 
    <delete>
     <fileset dir="classes"
       includes="**/*.class"/>
    </delete>
 
    <mkdir dir="build/WEB-INF"/>
    <mkdir dir="build/WEB-INF/lib"/>
 
    <copy file="etc/web.xml" todir="build/WEB-INF"/>
    <copy file="etc/geronimo-jetty.xml" todir="build/WEB-INF"
       failonerror="false"/>
    <copy todir="build">
      <fileset dir="web"/>
    </copy>
  </target>
 
  <target name="compile" depends="prepare">
    <javac srcdir="src" destdir="classes"
           debug="on" optimize="off" deprecation="off">
      <classpath refid="cp"/>
    </javac>
  </target>
 
  <target name="jar" depends="compile">
    <jar jarfile="build/WEB-INF/lib/gtest-ejbs.jar">
     <fileset dir="classes"
       includes="**/*.class"/>
     <metainf dir="etc" includes="ejb-jar.xml,openejb-jar.xml"/>
    </jar>
  </target>
 
  <target name="war" depends="jar">
    <war destfile="dist/gtest.war" webxml="build/WEB-INF/web.xml">
      <fileset dir="build">
        <exclude name="WEB-INF/web.xml"/>
      </fileset>
    </war>
  </target>
 
  <target name="ear" depends="war">
    <copy todir="dist" file="build/WEB-INF/lib/gtest-ejbs.jar"/>
    <ear destfile="dist/gtest.ear" appxml="etc/application.xml">
      <fileset dir="dist" includes="*.war,*.jar"/>
    </ear>
  </target>
 
</project>



As you can see, this build file contains commands to build not just our Web application, but also our J2EE application. You will have to edit the one <property> tag at the top of the build file for your purposes. Make sure it points to the Geronimo binary installation directory. In my case, it points to the symbolic link I just created.

For now, we want only a simple war file. So, type the following (make sure you are in $GERONIMO_DEVEL):

 ant war



This command creates a file called gtest.war in the dist subdirectory. It should not produce an error, since no compilation is involved.

1 | 2 | 3 | 4 | 5 | 6 |  Next >

Discuss

Start a new discussion or jump into one of the threads below:

Subject Replies Last post
. A first look at Apache Geronimo
By JavaWorldAdministrator
19 11/22/06 05:58 PM
by Anonymous
. where's the code?
By Anonymous
1 02/15/06 06:19 PM
by Anonymous
. Open Source Response Now Published
By Lajos
0 01/07/05 12:47 PM
by Anonymous
. "What is open source" response
By Lajos
0 12/21/04 11:14 AM
by Anonymous
. Nice article thank you
By Anonymous
0 12/13/04 03:31 PM
by Anonymous
. Ant?
By Anonymous
0 12/13/04 01:15 PM
by Anonymous


Resources