blob: c42241d97c247b8490b9d183ee07db163dac3d43 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>2.3&nbsp;Building and Installing GreenPages</title><link rel="stylesheet" href="css/stylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="A Guide to the GreenPages Sample"><link rel="up" href="ch02.html" title="2.&nbsp;Installing and Running GreenPages"><link rel="prev" href="ch02s02.html" title="2.2&nbsp;Obtaining GreenPages"><link rel="next" href="ch02s04.html" title="2.4&nbsp;Browsing the GreenPages Application"><!--Begin Google Analytics code--><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
var pageTracker = _gat._getTracker("UA-2728886-3");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
</script><!--End Google Analytics code--></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.3&nbsp;Building and Installing GreenPages</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02s02.html">Prev</a>&nbsp;</td><th width="60%" align="center">2.&nbsp;Installing and Running GreenPages</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ch02s04.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="installing.greenpages.building"></a>2.3&nbsp;Building and Installing GreenPages</h2></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="installing.greenpages.building.mvn"></a>Building with Apache Maven</h3></div></div></div><p>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:
</p><div class="orderedlist"><ol type="1"><li><p>Make <code class="code">$GREENPAGES_HOME/</code> the current directory.</p></li><li><p>Run the command
<code class="code">mvn package</code>. The first time this is run several files will be downloaded
from Maven repositories. Subsequent runs will not need to do this.
</p></li><li><p>Verify that the
<code class="code">greenpages-2.5.0.RELEASE.par</code> file exists in
<code class="code">$GREENPAGES_HOME/greenpages/target</code>.
</p></li></ol></div><p>
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="installing.greenpages.building.par.provided"></a>Installing Dependencies into Virgo Tomcat Server</h3></div></div></div><p>
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.
</p><p>The Maven build included with GreenPages uses the <code class="code">dependency:copy-dependencies</code> 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
<code class="code">package</code> phase. These dependencies can be found in
<code class="literal">$GREENPAGES_HOME/greenpages/target/par-provided</code>. To install dependencies
simply copy all the <code class="code">*.jar</code> files from this directory into <code class="literal">$SERVER_HOME/repository/usr</code>
(where <code class="literal">$SERVER_HOME</code> is the Virgo Tomcat Server installation directory).
</p><p>Installing dependencies on Windows:
</p><pre class="programlisting">prompt&gt; cd %GREENPAGES_HOME%\greenpages
prompt&gt; copy target\par-provided\* %SERVER_HOME%\repoorg.apache.commons.fileuploadsitory\usr
</pre><p>
</p><p>Installing dependencies on UNIX:
</p><pre class="programlisting">prompt$ cd $GREENPAGES_HOME/org.apache.commons.fileuploadgreenpages
prompt$ cp target/par-provided/* $SERVER_HOME/repository/usr
</pre><p>
</p><p>
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).
The <code class="literal">usr</code> 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 <code class="literal">-clean</code> 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 <code class="literal">-clean</code> option.
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="installing.greenpages.building.db"></a>Starting and Configuring the Database</h3></div></div></div><p>GreenPages uses the H2 database to store all its data. Before starting the application, start the database server and populate the database with data.</p><div class="orderedlist"><ol type="1"><li><p>Change to the <code class="code">$GREENPAGES_HOME/db</code> current directory. On Unix:</p><pre class="programlisting">prompt$ cd $GREENPAGES_HOME/db</pre><p>On Windows:</p><pre class="programlisting">prompt&gt; cd %GREENPAGES_HOME%\db</pre></li><li><p>Run the database startup script appropriate to the operating system. For Unix, this is <code class="literal">run.sh</code>, run in the background:</p><pre class="programlisting">prompt$ sh run.sh &amp;</pre><p>Press Return to continue.</p><p>On Windows, run the <code class="literal">run.bat</code> command:</p><pre class="programlisting">prompt&gt; run</pre><p>For both platforms, the command might invoke a browser window offering a connection to the database; close this window.</p></li><li><p>Run the data population script appropriate to the operating system. For Unix, this is <code class="literal">data.sh</code>:</p><pre class="programlisting">prompt$ sh data.sh</pre><p>On Windows, run the <code class="literal">data.bat</code> command:</p><pre class="programlisting">prompt&gt; data</pre></li></ol></div><p>
Run these commands once to start a database server for H2; the server will continue to run in the background.
</p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="installing.greenpages.building.par"></a>Installing and Starting GreenPages PAR</h3></div></div></div><p>To install the GreenPages PAR into Virgo Tomcat Server and start it:
</p><div class="orderedlist"><ol type="1"><li><p>Copy the GreenPages PAR to the <code class="code">$SERVER_HOME/pickup</code> directory. On Unix:</p><pre class="programlisting">prompt$ cd $SERVER_HOME
prompt$ cp $GREENPAGES_HOME/greenpages/target/greenpages-2.5.0.RELEASE.par pickup/</pre><p>On Windows:</p><pre class="programlisting">prompt&gt; cd %SERVER_HOME%
prompt&gt; copy %GREENPAGES_HOME%\greenpages\target\greenpages-2.5.0.RELEASE.par pickup\</pre></li><li><p>Start Virgo Tomcat Server with the <code class="literal">-clean</code> option. On Unix:</p><pre class="programlisting">prompt$ $SERVER_HOME/bin/startup.sh -clean</pre><p>On Windows:</p><pre class="programlisting">prompt&gt; "%SERVER_HOME%"\bin\startup.bat -clean</pre></li><li><p>Verify that GreenPages starts correctly by checking in the Virgo Tomcat Server output for the log message:
</p><pre class="programlisting">&lt;DE0005I&gt; Started par 'greenpages' version '2.5.0.RELEASE'. </pre><p>
</p></li></ol></div><p>
</p></div></div><!--Begin LoopFuse code--><script src="http://loopfuse.net/webrecorder/js/listen.js" type="text/javascript"></script><script type="text/javascript">
_lf_cid = "LF_48be82fa";
_lf_remora();
</script><!--End LoopFuse code--><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02s02.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="ch02.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ch02s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2.2&nbsp;Obtaining GreenPages&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;2.4&nbsp;Browsing the GreenPages Application</td></tr></table></div></body></html>