HomeApache Geronimo v1.0 > Documentation > Apache Geronimo v1.0 - Developer's Guide > Application frameworks > Spring


Spring is a layered Java/J2EE application framework, based on code published in Expert One-on-One J2EE Design and Development. Throughout this article we will be using Apache Geronimo v1.0 and Spring Framework 1.2.7 as it is the latest release for production. Refer to http://www.springframework.org/ for additional details.

The focus of this article is not to show you how to customize nor develop applications with Spring but to show you the integration in Apache Geronimo. In this article you will find step-by-step instructions for configuring and deploying the sample applications provided by the framework. Some of these sample applications accept more that one configuration, we will attempt to cover all these configurations.

This article is organized in the following sections:

Technologies offered by the framework

  • A complete lightweight container
  • A common abstraction layer for transaction management
  • A JDBC abstraction layer
  • Integration with Toplink, Hibernate, JDO, and iBATIS SQL Maps
  • AOP functionality
  • A flexible MVC web application framework

Back to Top

Prerequisites

The following software should be installed and configured in order to run the samples covered in this article.

J2SE 1.4.2

Geronimo is currently using the Sun ORB for RMI so it is required to use SUN JDK. These sample applications require as a minimum JDK 1.3. Refer to the following URL for details on how to download and install J2SE 1.4.2:
http://java.sun.com

Apache Ant 1.5

Apache Ant 1.5 or later is required for building the sample application. Ant can be downloaded from the following URL:
http://ant.apache.org

SpringFramework 1.2.7

This article is based on the use of SpringFramework 1.2.7.
http://www.springframework.org/

Apache Geronimo v1.0

All the sample applications covered in this article will be deployed to Apache Geronimo v1.0.
http://geronimo.apache.org/

Back to Top

Sample applications

Spring comes with a series of sample applications for demonstrating the different features covered by the framework. This section provides a high level overview of these sample applications, what are the technologies each of these applications make focused on and how to make them work in Apache Geronimo.

The sample applications provided with the SpringFramework 1.2.7 are:

Countries

The Countries sample application covers the use of advanced features in the presentation layer. The Spring Countries sample application heavily focuses on:

  • Localization
  • Themes
  • Refreshable paged list
  • Composed views
  • Internationalized views
  • Arborescent view definitions
  • A personalized interceptor

This application lists country's code, lets you search by country code and name, allows you to export the search results in both pdf and excel formats. This application also provides three different themes and three different languages to choose from.

This sample application can be used in three different configurations:

  1. Configuration simple
    • The list of the countries is generated in memory.
    • No data base is used.
    • It is the configuration provided at the beginning.
  2. Configuration copy
    • The list of the countries is generated in memory.
    • The data base is used only to be populated by the list in memory.
    • The application detects this configuration automatically and proposes a choice copy from the home page.
  3. Configuration data base
    • The list of the countries is read from the data base.

You should have tested the copy configuration and used successfully the copy in the data base function to be able to use this configuration.

Refer to the application's readme.txt for further details.

Configuration simple

This is the configuration by default, we will just add a Geronimo specific deployment plan to ensure the usage of the Spring jars deployed with the web application.

Create deployment plan

To create a Geronimo specific deployment plan geronimo-web.xml follow these steps.

  • Create a geronimo-web.xml deployment plan file in the <spring_home>\samples\countries\war\WEB-INF directory.
  • Edit the deployment plan and add the following content:
    geronimo-web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
                    configId="org/springframework/samples/countries">
      <!-- force the usage of the Spring jars deployed with the web application -->
        <hidden-classes>
          <filter>org.springframework</filter>
        </hidden-classes>
        <context-root>/countries</context-root>
        <context-priority-classloader>false</context-priority-classloader>
    </web-app>

Build application

To build the application an Ant build script is provided, this script has the following targets available:

  • clean, clean output directories.
  • build, compile main Java sources and copy libraries.
  • docs, create complete Javadoc documentation.
  • warfile, build the web application archive.
  • all, clean, build, docs, warfile.

Run the following command from the <spring_home>\samples\countries directory.
build all

This will create the countries.war file in the <spring_home>\samples\countries\dist directory. This is the file we will use for deploying to Apache Geronimo.

Deploy application

To deploy the sample application we will use the command line option. Run the following command from the <geronimo_home>\bin directory:

deploy --user system --password manager deploy <spring_home>\samples\countries\dist\countries.war

In order to use the deployer tool, the Apache Geronimo server has to be running.

Once the application has been successfully deployed you should see a confirmation message similar to this example.

E:\geronimo-1.0\bin>deploy --user system --password manager deploy \spring-framework-1.2.7\samples\countries\dist\countries.war
    Deployed org/springframework/samples/countries @
    http://hcunico:8080/countries

Test application

When you deploy an application from the command line using the deployer tool you will receive as a part of the confirmation message the URL (context root) for testing the application.

Open a web browser and access the following URL:

http://localhost:8080/countries

Click on the different links from the navigation menu on the left.

Configuration copy

NOT TESTED
In countries-servlet.xml, comment on part ONLY MEMORY OR ONLY DATABASE IMPLEMENTATION. Uncomment on part MEMORY+DATABASE IMPLEMENTATION FOR COPYING FROM MEMORY TO DATABASE.

In applicationContext.xml, comment on part In memory only version. Uncomment on part In memory + Database version for copying

Configuration data base

NOT TESTED
In countries-servlet.xml, comment on part MEMORY+DATABASE IMPLEMENTATION FOR COPYING FROM MEMORY TO DATABASE. Uncomment on part ONLY MEMORY OR ONLY DATABASE IMPLEMENTATION. You thus returned to the starting situation.

In applicationContext.xml, comment on part In memory + Database version for copying. Uncomment on part Database only version.

Back to Top

ImageDb

The ImageDb sample application make special focus on a couple of features that are not covered by any of the other sample applications. This particular features are:

  • BLOB/CLOB handling via a LobHandler (addressing Oracle's peculiar behavior).
  • retrieving underlying native Connections from pools via NativeJdbcExtractor.
  • HTTP multipart file uploads via MultipartResolver.
  • integration of Velocity as view technology for Spring's web MVC.

ImageDb sample application uses by default MySQL, in this section we will modify the default configuration to use the Geronimo embedded database, Derby. The following steps will show you how to configure, build and deploy this sample application in Apache Geronimo.

Refer to the application's readme.txt for further details.

Create deployment plan

To create a Geronimo specific deployment plan geronimo-web.xml follow these steps.

  • Create a geronimo-web.xml deployment plan file in the <spring_home>\samples\imagedb\war\WEB-INF directory.
  • Edit the deployment plan and add the following content:
    geronimo-web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
                  configId="org/springframework/samples/imagedb">
      <!-- force the usage of the Spring jars deployed with the web application -->
        <hidden-classes>
          <filter>org.springframework</filter>
        </hidden-classes>
        <context-root>/imagedb</context-root>
        <context-priority-classloader>false</context-priority-classloader>
    </web-app>

Create database in Geronimo using the embedded database

To create a database in Geronimo follow these steps.

  • Ensure Apache Geronimo is up and running. If it is not running start it by typing the following command:
    <geronimo_home>\bin\geronimo run
  • Access the Geronimo Administration Console by pointing a Web browser to the following URL:
    http://localhost:8080/console
  • Enter system as the user name and manager as the password.
  • In the Console Navigation on the left hand side scroll all the way down and click on DB Manager.
  • In the Create DB: field enter imagedb as the database name and click Create.
  • Create the necessary tables to run this sample application by entering the following SQL statement in the SQL Command/s: field. Make sure you select imagedb from the Use DB: pull-down menu.
    CREATE TABLE imagedb (
      image_name VARCHAR(255) NOT NULL PRIMARY KEY,
      content BLOB,
      description VARCHAR(255)
    );
  • Click Run SQL.
  • You should see the confirmation message SQL command/s successful.

Additional details on starting the server and creating databases can be found in the Administrative tasks section.

Create connection pool

The following steps summarizes the steps needed to create a database connection pool. Refer to Configuring database pools for further details.

  • From the Geronimo Administration Console click on Database Pools in the Console Navigation menu on the left hand side.
  • Use the wizard to create a new connection pool by clicking on Using the Geronimo database pool wizard.
  • Enter imagedb in the Name of Database Pool:.
  • Select Derby Embedded from the Database Type: pull-down menu and click Next.
  • Note the JDBC Driver Class: org.apache.derby.jdbc.EmbeddedDriver, you will need it later when configuring the JDBC properties.
  • Select org.apache.derby/derby/10.1.1.0/jar from the Driver JAR: pull-down menu.
  • Clean up the fields for DB User Name: and DB Password:, you do not need to specify user name and password when using the embedded database.
  • Enter imagedb in the Database: field and click Next.
  • Note the JDBC Connect URL: jdbc:derby:imagedb, you will need it later when configuring the JDBC properties.
  • Click on Skip Test and Deploy.

Update JDBC connection properties

You now need to update the JDBC connection properties to point to the newly configured Derby database. Edit the jdbc.properties file located in the <spring_home>\samples\imagedb\war\WEB-INF directory to reflect the changes shown in the following example.

jdbc.properties
# Properties file with JDBC-related settings.
# Applied by PropertyPlaceholderConfigurer from "applicationContext.xml".
# Targeted at system administrators, to avoid touching the context XML files.

#jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.driverClassName=org.apache.derby.jdbc.EmbeddedDriver

#jdbc.url=jdbc:mysql://localhost:3306/imagedb
jdbc.url=jdbc:derby:imagedb

#jdbc.username=root
jdbc.username=

#jdbc.password=password
jdbc.password=

imageDatabase.lobHandler=defaultLobHandler

#jdbc.driverClassName=oracle.jdbc.OracleDriver
#jdbc.url=jdbc:oracle:thin:@localhost:1521:imagedb
#jdbc.username=scott
#jdbc.password=tiger
#imageDatabase.lobHandler=oracleLobHandler

Update Mail properties

For this example we will not be testing the mail functionality of this sample application hence we will "disable" this feature. Edit the mail.properties file located in the <spring_home>\samples\imagedb\war\WEB-INF directory to reflect the changes shown in the following example.

mail.properties
# Properties file with mail-related settings, used for scheduled info emails.
# Applied by PropertyPlaceholderConfigurer from "applicationContext.xml".
# Targeted at system administrators, to avoid touching the context XML files.

mail.host=

#[email protected]
mail.from=

#[email protected]
mail.to=

Build the application

At this point we have done all the changes needed to the configurations in order to run this sample application in Apache Geronimo. To build the application an Ant build script is provided, this file has the following targets available:

  • clean, clean output directories.
  • build, compile main Java sources and copy libraries.
  • warfile, build the web application archive.
  • all, clean, build, warfile.

To build the ImageDB sample application run the following command from the <spring_home>\samples\imagedb directory.

build all

This will create the imagedb.war file in the <spring_home>\samples\imagedb\dist directory. This is the file we will use for deploying to Apache Geronimo.

Deploy the application

To deploy the sample application we will use the command line option. Run the following command from the <geronimo_home>\bin directory:

deploy --user system --password manager deploy <spring_home>\samples\imagedb\dist\imagedb.war

In order to use the deployer tool, the Apache Geronimo server has to be running.

Once the application has been successfully deployed you should see a confirmation message similar to this example.

E:\geronimo\bin>deploy --user system --password manager deploy \spring-framework-1.2.7\samples\imagedb\dist\imagedb.war
    Deployed org/springframework/samples/imagedb @
    http://hcunico:8080/imagedb

Test application

When you deploy an application from the command line using the deployer tool you will receive as a part of the confirmation message the URL (context root) for testing the application.

Open a web browser and access the following URL:

http://localhost:8080/imagedb

You will be presented with a simple form where you can specify Name (file name alias), Content (browse the file) and Description. Try to upload a few images, you can see how these images are being stored in the Derby database by using the Geronimo Administration Console. Click on DB Manager, then click on Application corresponding to the imagedb database. Now click on View Contents for the IMAGEDB table (there should be just one table). You should see IMAGE_NAME, CONTENT and DESCRIPTION as you entered in the forms.

There were some errors while uploading images stored in long name directories, as a workaround you can upload applications from the root directory.

Back to Top

JPetStore

JPetStore is a Spring-managed middle tier with iBATIS Database Layer as data access strategy, in combination with Spring's transaction and DAO abstractions. Can work with local JDBC transactions or JTA. JPetStore uses the same data model and demo contents as the original, well known, JPetStore; see http://ibatis.apache.org for details.

This version of JPetStore has an improved internal structure and loose coupling. This version of JPetStore also demonstrates various remoting options with Spring: Hessian, Burlap, RMI, and Web Services via Apache Axis. They are all provided out-of-the-box by the default web application. The "client" directory contains a simple command-line client that invokes the exported OrderService via all protocols.

Refer to the application's readme.txt for further details.

Create deployment plan

To create a Geronimo specific deployment plan geronimo-web.xml follow these steps.

  • Create a geronimo-web.xml deployment plan file in the <spring_home>\samples\jpetstore\war\WEB-INF directory.
  • Edit the deployment plan and add the following content:
geronimo-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
               configId="org/springframework/samples/jpetstore">
  <!-- force the usage of the Spring jars deployed with the web application -->
  <hidden-classes>
    <filter>org.springframework</filter>
  </hidden-classes>
  <context-root>/jpetstore</context-root>
  <context-priority-classloader>false</context-priority-classloader>
</web-app>

Create database in Geronimo using the embedded database

To create a database in Geronimo follow these steps.

  • Ensure Apache Geronimo is up and running. If it is not running start it by typing the following command:
    <geronimo_home>\bin\geronimo run
  • Access the Geronimo Administration Console by pointing a Web browser to the following URL:
    http://localhost:8080/console
  • Enter system as the user name and manager as the password.
  • In the Console Navigation on the left hand side scroll all the way down and click on DB Manager.
  • In the Create DB: field enter jpetstore as the database name and click Create.
  • Create the necessary tables to run this sample application by entering the copying and pasting from the attached jpetstore-derbydb-schema.sql in the SQL Command/s: field. Make sure you select jpetstore from the Use DB: pull-down menu.
  • Click Run SQL.
  • You should see the confirmation message SQL command/s successful.

Load the sample data

You will need to load some sample data to run this sample application. While still in the DB Manager copy and paste the content from the attached jpetstore-derbydb-dataload.sql into the SQL Command/s: field. Make sure you select jpetstore from the Use DB: pull-down menu.

  • Click Run SQL.
  • You should see the confirmation message SQL command/s successful.

Create connection pool

The following steps summarizes the steps needed to create a database connection pool. Refer to Configuring database pools for further details.

  • From the Geronimo Administration Console click on Database Pools in the Console Navigation menu on the left hand side.
  • Use the wizard to create a new connection pool by clicking on Using the Geronimo database pool wizard.
  • Enter jpetstore in the Name of Database Pool:.
  • Select Derby Embedded from the Database Type: pull-down menu and click Next.
  • Note the JDBC Driver Class: org.apache.derby.jdbc.EmbeddedDriver, you will need it later when configuring the JDBC properties.
  • Select org.apache.derby/derby/10.1.1.0/jar from the Driver JAR: pull-down menu.
  • Clean up the fields for DB User Name: and DB Password:, you do not need to specify user name and password when using the embedded database.
  • Enter jpetstore in the Database: field and click Next.
  • Note the JDBC Connect URL: jdbc:derby:jpetstore, you will need it later when configuring the JDBC properties.
  • Click on Skip Test and Deploy.

Update JDBC connection properties

You now need to update the JDBC connection properties to point to the newly configured Derby database. Edit the jdbc.properties file located in the <spring_home>\samples\jpetstore\war\WEB-INF directory to reflect the changes shown in the following example.

jdbc.properties
# Properties file with JDBC-related settings.
# Applied by PropertyPlaceholderConfigurer from "dataAccessContext-local.xml".
# Targeted at system administrators, to avoid touching the context XML files.

#jdbc.driverClassName=org.hsqldb.jdbcDriver
jdbc.driverClassName=org.apache.derby.jdbc.EmbeddedDriver

#jdbc.url=jdbc:hsqldb:hsql://localhost:9002
jdbc.url=jdbc:derby:jpetstore

#jdbc.username=sa
jdbc.username=

jdbc.password=

Build the application

At this point we have done all the changes needed to the configurations in order to run this sample application in Apache Geronimo. To build the application an Ant build script is provided, this file has the following targets available:

  • clean, clean output directories.
  • build, compile main Java sources and copy libraries.
  • warfile, build the web application archive.
  • all, clean, build, warfile.

To build the JPetStore sample application run the following command from the <spring_home>\samples\jpetstore directory.

build all

This will create the jpetstore.war file in the <spring_home>\samples\jpetstore\dist directory. This is the file we will use for deploying to Apache Geronimo.

Deploy the application

To deploy the sample application we will use the command line option. Run the following command from the <geronimo_home>\bin directory:

deploy --user system --password manager deploy <spring_home>\samples\jpetstore\dist\jpetstore.war

In order to use the deployer tool, the Apache Geronimo server has to be running.

Once the application has been successfully deployed you should see a confirmation message similar to this example.

E:\geronimo\bin>deploy --user system --password manager deploy \spring-framework-1.2.7\samples\jpetstore\dist\jpetstore.war
    Deployed org/springframework/samples/jpetstore @
    http://hcunico:8080/jpetstore

Test application

When you deploy an application from the command line using the deployer tool you will receive as a part of the confirmation message the URL (context root) for testing the application.

Open a web browser and access the following URL:

http://localhost:8080/jpetstore

Click on Enter the Store, browse the catalog and place an order. Once you placed the order you can see it reflected in the table ORDERS in the jpetstore database (use the DM Manager portlet from the Geronimo Administration Console).

Back to Top

PetClinic

Refer to the application's readme.txt for further details.

Create deployment plan

To create a Geronimo specific deployment plan geronimo-web.xml follow these steps.

  • Create a geronimo-web.xml deployment plan file in the <spring_home>\samples\petclinic\war\WEB-INF directory.
  • Edit the deployment plan and add the following content:
geronimo-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
              configId="org/springframework/samples/petclinic">
  <!-- force the usage of the Spring jars deployed with the web application -->
  <hidden-classes>
    <filter>org.springframework</filter>
  </hidden-classes>
  
  <!-- only required if using Hibernate -->
  <hidden-classes>
    <filter>antlr</filter>
  </hidden-classes>
  <context-root>/petclinic</context-root>
  <context-priority-classloader>false</context-priority-classloader>
</web-app>

Create database in Geronimo using the embedded database

To create a database in Geronimo follow these steps.

  • Ensure Apache Geronimo is up and running. If it is not running start it by typing the following command:
    <geronimo_home>\bin\geronimo run
  • Access the Geronimo Administration Console by pointing a Web browser to the following URL:
    http://localhost:8080/console
  • Enter system as the user name and manager as the password.
  • In the Console Navigation on the left hand side scroll all the way down and click on DB Manager.
  • In the Create DB: field enter petclinic as the database name and click Create.
  • Create the necessary tables to run this sample application by entering the copying and pasting from the attached petclinic-derbydb-schema.sql in the SQL Command/s: field. Make sure you select petclinic from the Use DB: pull-down menu.
  • Click Run SQL.
  • You should see the confirmation message SQL command/s successful.

Load the sample data

You will need to load some sample data to run this sample application. While still in the DB Manager copy and paste the content from the attached petclinic-derbydb-dataload.sql into the SQL Command/s: field. Make sure you select petclinic from the Use DB: pull-down menu.

  • Click Run SQL.
  • You should see the confirmation message SQL command/s successful.

Create connection pool

The following steps summarizes the steps needed to create a database connection pool. Refer to Configuring database pools for further details.

  • From the Geronimo Administration Console click on Database Pools in the Console Navigation menu on the left hand side.
  • Use the wizard to create a new connection pool by clicking on Using the Geronimo database pool wizard.
  • Enter petclinic in the Name of Database Pool:.
  • Select Derby Embedded from the Database Type: pull-down menu and click Next.
  • Note the JDBC Driver Class: org.apache.derby.jdbc.EmbeddedDriver, you will need it later when configuring the JDBC properties.
  • Select org.apache.derby/derby/10.1.1.0/jar from the Driver JAR: pull-down menu.
  • Clean up the fields for DB User Name: and DB Password:, you do not need to specify user name and password when using the embedded database.
  • Enter petclinic in the Database: field and click Next.
  • Note the JDBC Connect URL: jdbc:derby:petclinic, you will need it later when configuring the JDBC properties.
  • Click on Skip Test and Deploy.

Update JDBC connection properties

You now need to update the JDBC connection properties to point to the newly configured Derby database. Edit the jdbc.properties file located in the <spring_home>\samples\petclinic\war\WEB-INF directory to reflect the changes shown in the following example.

jdbc.properties
# Properties file with JDBC-related settings.
# Applied by PropertyPlaceholderConfigurer from "applicationContext-*.xml".
# Targeted at system administrators, to avoid touching the context XML files.

#jdbc.driverClassName=org.hsqldb.jdbcDriver
#jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.driverClassName=org.apache.derby.jdbc.EmbeddedDriver

#jdbc.url=jdbc:hsqldb:hsql://localhost:9001
#jdbc.url=jdbc:mysql://localhost:3306/petclinic
jdbc.url=jdbc:derby:petclinic

#jdbc.username=sa
jdbc.username=

jdbc.password=

# Property that determines the Hibernate dialect
# (only applied with "applicationContext-hibernate.xml")
#hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.dialect=org.hibernate.dialect.DerbyDialect

#hibernate.dialect=org.hibernate.dialect.MySQLDialect

# Property that determines the JDBC implementation of Clinic
# (only applied with "applicationContext-jdbc.xml")
petclinic.jdbcImplBeanName=hsqlClinic

#petclinic.jdbcImplBeanName=mysqlClinic

# Note that OJB expects the database platform to be set in
# "OJB-repository.xml" (jdbc-connection-descriptor platform).

Build the application

At this point we have done all the changes needed to the configurations in order to run this sample application in Apache Geronimo. To build the application an Ant build script is provided, this file has the following targets available:

  • clean, clean output directories.
  • build, compile main Java sources and copy libraries.
  • docs, create complete Javadoc documentation.
  • warfile, build the web application archive.
  • setupDB, initialize the database.
  • tests, run tests using initialized database.
  • all, clean, build, docs, warfile, tests.

To build the JPetStore sample application run the following command from the <spring_home>\samples\jpetstore directory.

build clean
build warfile

This will create the petclinic.war file in the <spring_home>\samples\petclinic\dist directory. This is the file we will use for deploying to Apache Geronimo.

Deploy the application

To deploy the sample application we will use the command line option. Run the following command from the <geronimo_home>\bin directory:

deploy --user system --password manager deploy <spring_home>\samples\petclinic\dist\petclinic.war

In order to use the deployer tool, the Apache Geronimo server has to be running.

Once the application has been successfully deployed you should see a confirmation message similar to this example.

E:\geronimo\bin>deploy --user system --password manager deploy \spring-framework-1.2.7\samples\petclinic\dist\petclinic.war
    Deployed org/springframework/samples/petclinic @
    http://hcunico:8080/petclinic

Test application

When you deploy an application from the command line using the deployer tool you will receive as a part of the confirmation message the URL (context root) for testing the application.

Open a web browser and access the following URL:

http://localhost:8080/petclinic

Click on Find owner, enter Davis for instance (the search is case sensitive). The search will retrieve the two owners with that last name. By clicking on the owner button you can access the owner information and edit it as well as list and edit pets and visits.

Back to Top

Tiles-example

The Tiles-example is simple application that shows the integration of Tiles in Web applications using Spring. This sample application includes two templates and three content JSPs. One of those templates automatically import news directly from Slashdot, TheServerside or JavaBlogs. Refer to the application's readme.txt for further details.

The following steps will show you how to build and deploy this sample application in Apache Geronimo.

Create deployment plan

Before you build this application you will need to create a Geronimo specific deployment plan geronimo-web.xml as described in the following steps.

  • Create a geronimo-web.xml deployment plan file in the <spring_home>\samples\tiles-example\war\WEB-INF directory.
  • Edit the deployment plan and add the following content:
    geronimo-web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
                    configId="org/springframework/samples/tiles">
      <!-- force the usage of the Spring jars deployed with the web application -->
        <hidden-classes>
          <filter>org.springframework</filter>
        </hidden-classes>
        <context-root>/tiles</context-root>
        <context-priority-classloader>false</context-priority-classloader>
    </web-app>

Build application

To build the application an Ant build xml file is provided, this file has the following targets available:

  • clean, clean output directories.
  • build, compile main Java sources and copy libraries.
  • docs, create complete Javadoc documentation.
  • warfile, build the web application archive.

To build the tiles-example sample application run the following commands from the <spring_home>\samples\tiles-example directory.

build clean (recommended if this is not your first build)
build build
build docs
build warfile

This will create the tiles-example.war file in the <spring_home>\samples\tiles-example\dist directory. This is the file we will use for deploying to Apache Geronimo.

Deploy application

To deploy the sample application we will use the command line option. Run the following command from the <geronimo_home>\bin directory:

deploy --user system --password manager deploy <spring_home>\samples\tiles-example\dist\tiles-example.war

In order to use the deployer tool, the Apache Geronimo server has to be running.

Once the application has been successfully deployed you should see a confirmation message similar to this example.

E:\geronimo-1.0-Tomcat.06-03-06\bin>deploy --user system --password manager deploy
\spring-framework-1.2.7\samples\tiles-example\dist\tiles-example.war
    Deployed org/springframework/samples/tiles @
    http://hcunico:8080/tiles

Test application

When you deploy an application from the command line using the deployer tool you will receive as a part of the confirmation message the URL (context root) for testing the application.

Open a web browser and access the following URL:

http://localhost:8080/tiles

Back to Top

WebApp-minimal

This sample application provides the most basic skeleton for a Web application using Spring. It shows the necessary web.xml and Spring-specific configuration (in the WEB-INF directory) for a complete application. It also provides a build script and simple structure for your application. Refer to the application's readme.txt for further details.

For this sample application you will not need to provide a Geronimo specific deployment plan given that it is a very simple application.

Build application

To build the application an Ant build xml file is provided, this file has the following targets available:

  • clean, clean output directories.
  • build, compile main Java sources and copy libraries.
  • warfile, build the web application archive.

Before you build the application you will need to copy some .jar files to the <spring_home>\samples\webapp-minimal\lib directory, the files you need to copy are:

  • <spring_home>\dist\spring.jar
  • <spring_home>\lib\jakarta-commons\commons-logging.jar
  • <spring_home>\lib\j2ee\servlet-api.jar

To build the WebApp-minimal sample application run the following commands from the <spring_home>\samples\webapp-minimal directory.

ant clean (recommended if this is not your first build)
ant build
ant warfile

This will create the minimal.war file in the <spring_home>\samples\webapp-minimal\dist directory. This is the file we will use for deploying to Apache Geronimo.

Deploy application

To deploy the sample application we will use the command line option. Run the following command from the <geronimo_home>\bin directory:

deploy --user system --password manager deploy <spring_home>\samples\webapp-minimal\dist\minimal.war

In order to use the deployer tool, the Apache Geronimo server has to be running.

Once the application has been successfully deployed you should see a confirmation message similar to this example.

E:\geronimo-1.0\bin>deploy --user system --password manager deploy \spring-framework-1.2.7\samples\webapp-minimal\dist\minimal.war
    Deployed minimal @ http://hcunico:8080/minimal

Note that since we did not provided any deployment descriptor, Geronimo is using by default the name of the war file as the configID and context root for deploying this application.

Test application

When you deploy an application from the command line using the deployer tool you will receive as a part of the confirmation message the URL (context root) for testing the application.

Open a web browser and access the following URL:

http://localhost:8080/minimal

Back to Top

Summary

Back to Top