GreenPages uses Apache Maven as its primary build system. Each module 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:
Make $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 and SpringSource repositories. Subsequent runs will not need to do this.
Verify that the
greenpages-2.1.0.RELEASE.par
file exists in
$GREENPAGES_HOME/solution/greenpages/target
.
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 dm Server, these dependencies can be loaded into memory as needed, but first they must be made available to dm 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 dm Server runtime. These dependencies
can then be installed into the dm 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 $DMS_HOME/repository/usr
.
Installing dependencies on Windows:
prompt> cd %GREENPAGES_HOME%\solution\greenpages prompt> copy target\par-provided\* %DMS_HOME%\repository\usr
Installing Dependencies on UNIX:
prompt$ cd $GREENPAGES_HOME/solution/greenpages prompt$ cp target/par-provided/* $DMS_HOME/repository/usr
Notice that dm 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).
The usr
repository is active so there is no
need to restart dm Server when copying these files.
The next time dm Server is started the -clean
option will cause dm Server to re-scan the repository directories in any case.
It is always safe to start dm Server with the -clean
option.
GreenPages uses the H2 database to store all its data. Before you can start the application, you must 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
On Windows:
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 run.bat
command:
prompt> run
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 data.sh
:
prompt$ sh data.sh
On Windows, run the data.bat
command:
prompt> data
You only to need 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 dm Server and start it:
Copy the GreenPages PAR to the $DMS_HOME/pickup
directory. On Unix:
prompt$ cd $DMS_HOME prompt$ cp $GREENPAGES_HOME/solution/greenpages/target/greenpages-solution-2.1.0.RELEASE.par pickup/
On Windows:
prompt> cd %DMS_HOME% prompt> copy %GREENPAGES_HOME%\solution\greenpages\target\greenpages-solution-2.1.0.RELEASE.par pickup\
Start dm Server with the -clean
option. On Unix:
prompt$ $DMS_HOME/bin/startup.sh -clean
On Windows:
prompt> "%DMS_HOME%"\bin\startup.bat -clean
Verify that GreenPages starts correctly by checking in the dm Server output for the log message:
<DE0005I> Started par 'greenpages' version '2.1.0.RELEASE'.