6.3 Form Tags Shared Libraries WAR
Prev | 6. Case Study: Migrating the Form Tags Sample Application | Next

## 6.3 Form Tags Shared Libraries WAR

As mentioned above, a standard WAR file typically packages of all its required dependencies in `WEB-INF/lib` . The servlet container will then add all of the JARs in `WEB-INF/lib` to the application’s classpath.

The first step of the migration towards benefiting from an OSGi container is to retrieve the dependencies from the VTS’s bundle repository at runtime. This can significantly reduce the time it takes to build and deploy the application. It also enables the enforcement of policies regarding the use of third-party libraries.

The way in which dependencies are declared in an OSGi environment is via manifest headers in a bundle’s `/META-INF/MANIFEST.MF` . As mentioned in Chapter 4, Developing Applications , there are three ways of expressing dependencies: `Import-Package` , `Import-Bundle` and `Import-Library` .

The Form Tags application uses JSTL standard tag libraries. Thus, you need to choose a JSTL provider, for example the Apache implementation which comes with the VTS. To use the Apache implementation of JSTL, you need to express your dependency as outlined in the following manifest listing. Because it is a single bundle, `Import-Bundle` is the simplest and therefore preferred manifest header to use.

The Form Tags application requires commons-logging and Spring. It would be very painful to have to list all the Spring packages one by one. Equally, considering the number of bundles that make up the Spring framework, it would be verbose to list each bundle. Therefore `Import-Library` is the preferred approach for expressing the dependency on the Spring framework.

| Tip
How do you determine the name of a library definition provided by the Virgo Server for Apache Tomcat? Use the SpringSource Enterprise Bundle Repository .

Examine the `/META-INF/MANIFEST.MF` in `/dist/formtags-shared-libs-*.war` :

    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.0
    Created-By: 1.5.0_13-119 (Apple Inc.)
    Bundle-ManifestVersion: 2
    Bundle-SymbolicName: org.springframework.showcase.formtags-shared-libs
    Import-Library: org.springframework.spring;version="[3.0.0,4.0.0)"
    Import-Bundle: com.springsource.org.apache.taglibs.standard;version="1
     .1.2"

You can see the `Import-Library` and `Import-Bundle` directives that instruct the VTS to add the appropriate package imports to the bundle classpath used by this WAR file.

Deploying the shared libraries WAR onto the VTS should result in console output similar to the following:

| Note
The console output has been reformatted to fit this document.

    [2009-07-01 15:00:14.953] fs-watcher
    	<SPDE0048I> Processing 'CREATED' event for file 'formtags-shared-libs-3.0.0.RELEASE.war'.
    [2009-07-01 15:00:15.363] fs-watcher
    	<SPDE0010I> Deployment of 'org.springframework.showcase.formtags_shared_libs' version '2' completed.
    [2009-07-01 15:00:15.364] Thread-20
    	<SPWE0000I> Starting web bundle '/formtags-shared-libs-3.0.0.RELEASE'.
    [2009-07-01 15:00:15.816] Thread-20
    	<SPWE0001I> Started web bundle '/formtags-shared-libs-3.0.0.RELEASE'.

Navigating to `http://localhost:8080/formtags-shared-libs-BUILDTAG` should render the welcome page. Note that for the pre-packaged distributable, the `BUILDTAG` should be similar to `3.0.0.RELEASE` ; whereas, for a local build the `-BUILDTAG` may be completely omitted. Please consult the console output, web-based admin console, or log to determine the exact context path under which the web application has been deployed.

Prev | Up | Next
6.2 Form Tags WAR | Home | 6.4 Form Tags Shared Services WAR