Deploying Your First Geronimo Application


To deploy your first Geronimo application, you will need the Enterprise Application Archive (EAR) file. This application is contained in progeron.ear. The application shows the names of the authors for this book. Download the EAR file for this chapter from the following URL:

www.wrox.com/WileyCDA/Section/id-105127.html

The progeron.ear is a standard J2EE EAR file. In fact, the same EAR file can be deployed on any J2EE 1.4–compatible server. With Geronimo, it is especially easy, since you will not need to create any additional Geronimo-specific deployment descriptors.

Important

Some seasoned J2EE administrator and deployers may challenge this simplicity, since EAR files in many production scenarios will require server-specific plans to be deployed successfully. If you fall into this category, please bear with us - the later chapters will fully explore Geronimo-specific deployment plans.

An EAR file is a deployable unit that can contain other archives file and Web components. In the case of progeron.ear, it contains the following:

  • A JSP template, called authors.jsp, used to present the list of authors

  • A ControllerServlet that coordinates the flow of requests, talks with the back-end EJB, and sends data to the JSP for presentation

  • A stateless session EJB, called Authors, that contains the author name data to be displayed

Figure 2-1 illustrates the operations of the progeron application.

image from book
Figure 2-1: The operations of the progeron application

In Figure 2-1, the EJB that contains the author names data is called Authors.EJB. There is also a JSP, called authors.jsp, that displays the table of authors. The ControllerServlet is the mediator. It accepts incoming requests, accesses the EJB for author information, and then forwards this information to the JSP for presentation to the user.

This EAR file is representative of a typical deployable enterprise application, with a variety of Web components inside the archive - including an EJB, a servlet, and JSP.

You can deploy this application on your Geronimo server in three different ways:

  1. Use the deployer command-line tool to deploy the EAR

  2. Use the Web console GUI to deploy the EAR

  3. Use Geronimo’s hot deployer to automatically deploy applications

This chapter provides coverage of 1 and 2. The hot deployer, while very easy to use, is typically used only by developers. In concept, any deployable archive you placed into the deploy subdirectory will be picked up by the hot deployer and deployed to the server. Chapter 6 provides detailed coverage of the hot deployer and its configuration.

Deploying Applications with the Geronimo Deployer Tool

You can use the deployer tool to deploy the application. The deployer can be found in the bin directory of your Geronimo distribution. There is a deploy.bat (or deploy.sh for Linux) that can be used immediately. For convenience, you should add the bin directory to your PATH environment variable.

The command to deploy the progeron.ear application is:

 deploy deploy progeron.ear

Of course, this assumes that progeron.ear is in the current directory. Otherwise, just enter the entire path to the EAR file as the last parameter. The first deploy in the previous line calls up the run-time-deployer via the deploy.bat (or deploy.sh) script; the second deploy specifies the deployment action to the run-time-deployer. When you enter this command, the deployer tool asks you for a username and password. Use the administrator username and password that you have entered during setup. If you have not changed it, the following default is available:

 user name:      system password:       manager

If your deployment is successful, you should see output similar to the following:

 >deploy deploy progeron.ear Username: system Password: Password:     Deployed default/progeron/11552985600093/car       `-> progeron.war @ http://myhostname:8080/progeron       `-> progeron-ejbs.jar

The deployer tool has just successfully deployed the progeron.ear file. The previous output provides the information shown in Table 2-1.

Table 2-1: Deployment Information Provided by the Deployer Tool
Open table as spreadsheet

Deployment Information

Description

Deployed default/progeron/11552985600093/car

The module (EAR file) that has been deployed.

A default module ID is generated by Geronimo.

progeron.war @ http://myhostname: 8080/progeron

The Web module (WAR file) that has been deployed to the Web application server, and the context root path at which this module has been deployed. In this case, conforming to standard J2EE requirement, the Web module (progeron.war) is actually contained within the EAR file (progeron.ear).

progeron-ejbs.jar

The EJB tier archive (JAR file) that has been deployed to the EJB server.

Figure 2-2 reveals the archive file bundling inside progeron.ear.

image from book
Figure 2-2: Inside the progeron.ear file

In Figure 2-2, you can see that both progeron.war and progeron-ejbs.jar are archived together within the progeron.ear file. In addition, a standard J2EE deployment descriptor for an enterprise application (called application.xml) is included. The following is the content of application.xml:

 <application         xmlns="http://java.sun.com/xml/ns/j2ee"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee        http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"        version="1.4">     <module>         <ejb>progeron-ejbs.jar</ejb>     </module>     <module>         <web>             <web-uri>progeron.war</web-uri>             <context-root>/ProGeronimo</context-root>         </web>     </module> </application>

This application.xml descriptor basically tells the server about the deployable units that are in the archive. Each one of the deployable units is destined for a different server inside Geronimo. Figure 2-3 illustrates how the two deployable units inside progeron.ear are deployed to the servers inside Geronimo.

image from book
Figure 2-3: Components inside progeron.ear are deployed to different servers

In Figure 2-3, the Web-tier components (such as JSP and servlets) are bundled inside progeron.war and are deployed to the Web-tier server in Geronimo. This server is either Jetty or Tomcat, depending on whether you have downloaded and installed the Jetty or Tomcat version of Geronimo. The context root at which the application is deployed is dependent on the <context-root> element in application.xml.

In this case, it is deployed at the context /ProGeronimo. The context root is the part of the URL used to access this application on the server. The following URL shows the context root portion highlighted:

http://localhost:8080/ProGeronimo/authors.cgi

The progeron-ejbs.jar is an archive of the EJBs for the application. It contains the stateless session EJB called Authors. Geronimo will deploy this archive of EJB to the OpenEJB server. The OpenEJB server is a container for EJBs, compatible with the latest EJB 2.1 standard.

Now that you know how to deploy an application to Geronimo from a command line, the next section will show you an even easier way - deployment via the graphical Web console.

Application Deployment Using the Geronimo Web Console

The Web console is a Web application itself, written as a set of servlets and JSPs. The default installation of Geronimo has the console already integrated.

With the Geronimo server running, all you need to do is to run the Web console is to access the following URL:

http://localhost:8080/console/

You will be greeted with the console’s login screen, shown in Figure 2-4.

image from book
Figure 2-4: Geronimo Web console login page

Enter the username and password that you have configured during setup, or use the default system-manager pair.

To see all the applications that are running on your server, look at the left panel for Application EARs, under the Application heading. Click on that. You should then see the right-hand side panel displaying the EARs portlet.

Important

A portlet is a developer’s term for a flexible GUI software component that can be used to compose a visual page displaying some application-specific information or a complete user interface. To us, it is simply whatever is displayed on the right-hand side of the browser screen.

Figure 2-5 shows the display of the portlet, listing the deployed progeron EAR.

image from book
Figure 2-5: The progeron.ear application deployed and running on Geronimo

In Figure 2-5, you can see three deployed application EARs - two running and one stopped. The running ones include the Web console application itself and also the progeron application; the Tomcat version of the UDDI (Universal Description, Discovery and Integration) server is also installed, but not started.

Before you can try and deploy the progeron application EAR again using the Web console, you must first uninstall it from the server. Geronimo remembers all the applications that are deployed to it, so you will still see the progeron application running even if you shut down and restart the server. To uninstall the progeron application, and reinstall it using the Web console, perform the following steps in sequence:

  1. In the Application EARs portlet, click on the Uninstall command link next to the default/progeron/11552985600093/car modules. This will stop the running application and then uninstall it from the server.

  2. Once the application has been successfully uninstalled, you should see it removed from the list of running Application EARs.

  3. Click on the Deploy New menu selection on the left-hand side of the page. You will see the Install New Applications portlet in the right-hand pane, as shown in Figure 2-6.

    image from book
    Figure 2-6: Installing the progeron.ear application via the Web console

  4. Click on the Browse... button, and select the progeron.ear, then click the Install button. Leaving the Start app after install checkbox checked.

This will deploy and start the application. You can click the Application EARs menu item on the left panel again and see that the application is now running (see Figure 2-7).

image from book
Figure 2-7: Confirming the installation and running of Application EARs

You can deploy applications to Geronimo via the command-line deployer or GUI-based Web console - it is your choice. The end result is the same. To confirm that the application is indeed running, you can access it using the following URL:

http://localhost:8080/ProGeronimo/authors.cgi

You will then see the list of authors from this book. The names are actually managed by the stateless session EJB. The servlets access the EJB to obtain the data, then pass it to the JSP for generating the displayed page.

Using the procedures detailed earlier, you can deploy a variety of J2EE application components to Geronimo. The next section details the possibilities.




Professional Apache Geronimo
Professional Apache Geronimo (Wrox Professional Guides)
ISBN: 0471785431
EAN: 2147483647
Year: 2004
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net