GreenPages uses Apache Maven as its primary build system. Each bundle of the application can be built separately and the entire application can built and assembled into a PAR file from a single location. To build the application and assemble it into a PAR file:
$GREENPAGES_HOME/solution the current directory.
Run the command
mvn package. The first time this is run several files will be downloaded
from Maven repositories. Subsequent runs will not need to do this.
Verify that the
greenpages-2.4.0.RELEASE.par file exists in
Unlike traditional Java EE applications, GreenPages does not package all of its dependencies inside its deployment unit. Instead, it relies on the mechanisms of OSGi to locate its dependencies at runtime. When running an OSGi application on Virgo Tomcat Server, these dependencies can be loaded into memory as needed, but first they must be made available to Virgo Tomcat Server.
The Maven build included with GreenPages uses the
dependency:copy-dependencies plugin to gather
all the artifacts that GreenPages depends on that are not supplied by the Virgo Tomcat Server runtime. These dependencies
can then be installed into the Virgo Tomcat Server repository. Dependencies are gathered automatically during the
package phase. These dependencies can be found in
$GREENPAGES_HOME/solution/greenpages/target/par-provided. To install dependencies
simply copy all the
*.jar files from this directory into
$SERVER_HOME is the Virgo Tomcat Server installation directory).
Installing dependencies on Windows:
prompt> cd %GREENPAGES_HOME%\solution\greenpages prompt> copy target\par-provided\* %SERVER_HOME%\repository\usr
Installing dependencies on UNIX:
prompt$ cd $GREENPAGES_HOME/solution/greenpages prompt$ cp target/par-provided/* $SERVER_HOME/repository/usr
Notice that Virgo Tomcat Server will not necessarily see these dependencies unless its repository indexes are rebuilt.
Different repositories behave differently in this respect; some are passive (their indexes are built only once upon startup)
and some are active (they can detect new files or files being removed dynamically).
usr repository is active so there is no
need to restart Virgo Tomcat Server when copying these files.
The next time Virgo Tomcat Server is started the
-clean option will cause Virgo Tomcat Server to re-scan the repository directories in any case.
It is always safe to start Virgo Tomcat Server with the
GreenPages uses the H2 database to store all its data. Before starting the application, start the database server and populate the database with data.
Change to the
$GREENPAGES_HOME/db current directory. On Unix:
prompt$ cd $GREENPAGES_HOME/db
prompt> cd %GREENPAGES_HOME%\db
Run the database startup script appropriate to the operating system. For Unix, this is
run.sh, run in the background:
prompt$ sh run.sh &
Press Return to continue.
On Windows, run the
For both platforms, the command might invoke a browser window offering a connection to the database; close this window.
Run the data population script appropriate to the operating system. For Unix, this is
prompt$ sh data.sh
On Windows, run the
Run these commands once to start a database server for H2; the server will continue to run in the background.
To install the GreenPages PAR into Virgo Tomcat Server and start it:
Copy the GreenPages PAR to the
$SERVER_HOME/pickup directory. On Unix:
prompt$ cd $SERVER_HOME prompt$ cp $GREENPAGES_HOME/solution/greenpages/target/greenpages-solution-2.4.0.RELEASE.par pickup/
prompt> cd %SERVER_HOME% prompt> copy %GREENPAGES_HOME%\solution\greenpages\target\greenpages-solution-2.4.0.RELEASE.par pickup\
Start Virgo Tomcat Server with the
-clean option. On Unix:
prompt$ $SERVER_HOME/bin/startup.sh -clean
prompt> "%SERVER_HOME%"\bin\startup.bat -clean
Verify that GreenPages starts correctly by checking in the Virgo Tomcat Server output for the log message:
<DE0005I> Started par 'greenpages' version '2.4.0.RELEASE'.