During development time, it can be helpful to run an application inside of the deployment container. In the case
of GreenPages, this means deploying the
greenpages.web bundle to the SpringSource dm Server.
The dm Server can be used while working in Eclipse.
In this step the
greenpages.web bundle is deployed and the dm Server instance is started.
greenpages.web project from the Package Explorer and drop it
on the dm Server instance in the Servers view.
greenpages.web is a web bundle the server will start automatically, and
a browser window may open.
Expand the dm Server instance and the bundle
greenpages.webwill be listed as a child.
(Eclipse may open its internal web browser as this is a web project. You can choose to use this or just close it and use another browser later.)
If deployment has gone successfully the console will contain the message
<DE0005I> Started bundle 'greenpages.web' version '2.0.0'.
Leave the server instance running and go to the next step.
The dm Server has special knowledge of web application bundles. In this step web bundle metadata is added to the bundle and a web browser is used to navigate to it.
Open a web browser and navigate to http://localhost:8080/greenpages. If the link is not currently served by any bundle in the dm Server there may be an error displayed:
or else there is a blank page displayed. No pages are served.
To fix this issue the
greenpages.web bundle must be declared to be a web bundle and a
context path defined.
template.mf file (at the top level under the
and add (and save) the following entry (using the template.mf pane of the editor):
Be careful not to insert any blank lines or trailing spaces in this file.
Once added, right-click on the
greenpages.web project and select
This will use a tool called Bundlor (included in STS) to update the OSGi metadata in the
MANIFEST.MF file. Once Bundlor has finished running, open the
META-INF/MANIFEST.MF file in the
It should look something like the following:
Manifest-Version: 1.0 Bundle-Name: GreenPages Web Import-Library: org.springframework.spring;version="[3.0, 3.1)" Import-Bundle: com.springsource.org.apache.taglibs.standard;version="[ 1.1.2,1.3)" Web-ContextPath: greenpages Import-Package: com.springsource.server.web.dm;version="[2.0.0, 3.0.0) ",freemarker.cache;version="[2.3.15,2.3.15]",javax.servlet.jsp.jstl.c ore;version="[1.1.2,1.2.0)",javax.sql,org.apache.commons.dbcp,org.spr ingframework.core.io,org.springframework.stereotype,org.springframewo rk.web.bind.annotation,org.springframework.web.context,org.springfram ework.web.servlet Bundle-ManifestVersion: 2 Bundle-Vendor: SpringSource Inc. Bundle-SymbolicName: greenpages.web Tool: Bundlor 1.0.0.M6 Bundle-Version: 2.0
although the order of the entries may be different.
The server (if it is still running) will track these changes and automatically refresh
(or restart) the
greenpages.web bundle as required.
Observe the context path for the web bundle being announced
(it should now be
whereas previously it would have been a default context path
derived from the bundle name:
By default, Bundlor generates
Import-Package entries with no version range specified.
In the absence of a version range, the OSGi default (which denotes any version) is used.
While this is very flexible it is generally a good idea to restrict an import by specifying a narrower range.
This can be achieved by providing Bundlor with some additional information in the manifest template,
as in the next step.
Add (and save) the following entry to the
Import-Template: org.springframework.*;version="[3.0.0, 3.1.0)"
(Again, be careful not to leave trailing spaces on lines or insert blank lines in this file.)
Re-run the MANIFEST.MF generation as described earlier.
MANIFEST.MF file the
should now have version ranges on each of the
Import-Package: com.springsource.server.web.dm;version="[2.0.0, 3.0.0) ",freemarker.cache;version="[2.3.15,2.3.15]",javax.servlet.jsp.jstl.c ore;version="[1.1.2,1.2.0)",javax.sql,org.apache.commons.dbcp,org.spr ingframework.core.io;version="[3.0.0, 3.1.0)",org.springframework.ste reotype;version="[3.0.0, 3.1.0)",org.springframework.web.bind.annotat ion;version="[3.0.0, 3.1.0)",org.springframework.web.context;version= "[3.0.0, 3.1.0)",org.springframework.web.servlet;version="[3.0.0, 3.1 .0)"
Behind the scenes the dm Server Tools have refreshed the deployed bundle as changes were made. Once again navigate to http://localhost:8080/greenpages. This page now displays an entry field.
Put any characters into the entry field and press Submit. This should display a “404” error page with the description:
description The requested resource () is not available.
This is because there is no search page (
search.htm) to process this request yet.
The next section will address this.