geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Geronimo v3.0 > Assembling a server using Maven
Date Fri, 28 Jan 2011 03:41:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2036/9/4/_/styles/combined.css?spaceKey=GMOxDOC30&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/Assembling+a+server+using+Maven">Assembling
a server using Maven</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~maojia508">maojia</a>
    </h4>
        <br/>
                         <h4>Changes (6)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-changed-lines" >Deploying applications with the
command line deployer or through the administration console is fine for experiments but does
not fit well into an automated development workflow.  <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">The</span>
<span class="diff-added-words"style="background-color: #dfd;">With the</span>
Geronimo plugin <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">system
lets</span> <span class="diff-added-words"style="background-color: #dfd;">system,</span>
you <span class="diff-added-words"style="background-color: #dfd;">can</span> set
up a workflow <span class="diff-added-words"style="background-color: #dfd;">by</span>
using maven that builds your applications, pre-deploys them as <span class="diff-changed-words"><span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">g</span><span
class="diff-added-chars"style="background-color: #dfd;">G</span>eronimo</span>
plugins, and assembles a server containing the plugins needed to run your applications.  Further
workflow steps could include automated testing by starting the custom server and <span
class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">running
e.g.</span> <span class="diff-added-words"style="background-color: #dfd;">running,
for example,</span> selenium tests against it. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">In
order to simplify setting up such an automated workflow we provide maven archetypes to help
with setting up maven projects to build plugins and assemble servers.  As an example we&#39;ll
describe setting up such a workflow for the liferay 4.4.1 portal.   Note that this is two
steps removed from a description of how to deploy liferay on geronimo, and one step removed
from a description of how to build plugins for the liferay portal. For a completed example
of such a workflow see the roller plugins at https://svn.apache.org/repos/asf/geronimo/plugins/roller/trunk
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">To
simplify setting up such an automated workflow, you can use maven archetypes, which can help
with setting up maven projects to build plugins and assemble servers.  As an example, this
topic describes setting up such a workflow for the liferay 4.4.1 portal.   Note that this
is two steps removed from a description of how to deploy liferay on geronimo, and one step
removed from a description of how to build plugins for the liferay portal. For a completed
example of such a workflow, see the roller plugins at https://svn.apache.org/repos/asf/geronimo/plugins/roller/trunk
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>Notes: <br></td></tr>
            <tr><td class="diff-changed-lines" ># <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Due
to</span> <span class="diff-added-words"style="background-color: #dfd;">Because
of</span> maven lifecycle improvements in the <span class="diff-changed-words">car-maven-plugin<span
class="diff-added-chars"style="background-color: #dfd;">,</span></span> the
assembly artifact only generates poms that work with Geronimo <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">2.1.1[-SNAPSHOT]</span>
<span class="diff-added-words"style="background-color: #dfd;">2.1.1-SNAPSHOT</span>
or later.  The archetypes are currently available only as snapshots from branches/2.1 and
trunk. <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">#
Maven tends to strip out all comments from the new pom.xml so a pom.sample.xml is included
that has more comments on how to set up the pom.xml for common situations. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">#
Maven tends to strip out all comments from the new pom.xml. Therefore, a pom.sample.xml that
has more comments on how to set up the pom.xml for common situations is included. <br></td></tr>
            <tr><td class="diff-unchanged" ># Archetypes use some attributes (groupId,
version) of parent projects when they exist.  The instructions use this: for standalone use
you may need to supply more command line options. <br># Some of this would not be necessary
given a project built with maven in the first place <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>Deploying applications with the command line deployer or through the administration
console is fine for experiments but does not fit well into an automated development workflow.
 With the Geronimo plugin system, you can set up a workflow by using maven that builds your
applications, pre-deploys them as Geronimo plugins, and assembles a server containing the
plugins needed to run your applications.  Further workflow steps could include automated testing
by starting the custom server and running, for example, selenium tests against it.</p>

<p>To simplify setting up such an automated workflow, you can use maven archetypes,
which can help with setting up maven projects to build plugins and assemble servers.  As an
example, this topic describes setting up such a workflow for the liferay 4.4.1 portal.   Note
that this is two steps removed from a description of how to deploy liferay on geronimo, and
one step removed from a description of how to build plugins for the liferay portal. For a
completed example of such a workflow, see the roller plugins at <a href="https://svn.apache.org/repos/asf/geronimo/plugins/roller/trunk"
class="external-link" rel="nofollow">https://svn.apache.org/repos/asf/geronimo/plugins/roller/trunk</a></p>

<p>Notes:</p>
<ol>
	<li>Because of maven lifecycle improvements in the car-maven-plugin, the assembly artifact
only generates poms that work with Geronimo 2.1.1-SNAPSHOT or later.  The archetypes are currently
available only as snapshots from branches/2.1 and trunk.</li>
	<li>Maven tends to strip out all comments from the new pom.xml. Therefore, a pom.sample.xml
that has more comments on how to set up the pom.xml for common situations is included.</li>
	<li>Archetypes use some attributes (groupId, version) of parent projects when they
exist.  The instructions use this: for standalone use you may need to supply more command
line options.</li>
	<li>Some of this would not be necessary given a project built with maven in the first
place</li>
	<li>As of writing, the server starts (given enough memory) but the liferay portal doesn't
show up.  Hopefully we'll figure out why soon.</li>
</ol>


<h1><a name="AssemblingaserverusingMaven-Processoverview."></a>Process overview.</h1>
<ol>
	<li>Get the necessary artifacts into the local maven repo if they are not already available</li>
	<li>Construct the base maven project</li>
	<li>Use the maven war archetype to build a project to modify the artifacts as necessary
using for instance the maven-war-plugin overlay to remove dependencies from WEB-INF/lib so
copies in geronimo's repository can be used</li>
	<li>Use the geronimo-plugin-archetype to build projects to build plugins for the components</li>
	<li>Use the geronimo-assembly-archetype to build a project to assemble the server.</li>
</ol>


<h2><a name="AssemblingaserverusingMaven-Preparationfindtheartifacts"></a>Preparation
&#8211; find the artifacts</h2>

<p>Liferay does not publish its code to any maven repo. Start by downloading:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
wget http:<span class="code-comment">//downloads.sourceforge.net/lportal/liferay-portal-4.4.1.war?modtime=1202491348&amp;big_mirror=1
</span>
wget http:<span class="code-comment">//downloads.sourceforge.net/lportal/liferay-portal-dependencies-4.4.1.zip?modtime=1202491352&amp;big_mirror=1</span>
</pre>
</div></div>

<p>unpacking:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
unzip liferay-portal-dependencies-4.4.1.zip
</pre>
</div></div>

<p>and installing to your local repo:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn install:install-file \
  -Dfile=liferay-portal-4.4.1.war \
  -DgroupId=com.liferay \
  -DartifactId=liferay-portal \
  -Dversion=4.4.1 \
  -Dpackaging=war

mvn install:install-file \
  -Dfile=liferay-portal-dependencies-4.4.1/portal-kernel.jar \
  -DgroupId=com.liferay \
  -DartifactId=portal-kernel \
  -Dversion=4.4.1 \
  -Dpackaging=jar

mvn install:install-file \
  -Dfile=liferay-portal-dependencies-4.4.1/portal-service.jar \
  -DgroupId=com.liferay \
  -DartifactId=portal-service \
  -Dversion=4.4.1 \
  -Dpackaging=jar
</pre>
</div></div>

<h2><a name="AssemblingaserverusingMaven-Setupaparentmavenproject"></a>Set
up a parent maven project</h2>


<p>I can't find an archetype to create an empty "parent" project.  So...<br/>
Find a suitable location and run</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DarchetypeArtifactId=maven-archetype-quickstart \
  -DarchetypeVersion=1.0 \
  -DgroupId=org.apache.geronimo.plugins \
  -DartifactId=liferay-parent \
  -Dversion=1.0-SNAPSHOT

cd liferay-parent
rm -rf src

</pre>
</div></div>
<p>Edit the pom.xml to change the packaging to pom and remove the dependency.</p>

<p>Also, until we publish a non-snapshot version of the archetypes, include this so
the archetypes can be downloaded automatically:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    &lt;pluginRepositories&gt;
        &lt;pluginRepository&gt;
            &lt;id&gt;apache-snapshots&lt;/id&gt;
            &lt;name&gt;Apache Snapshots Repository&lt;/name&gt;
            &lt;url&gt;http:<span class="code-comment">//people.apache.org/repo/m2-snapshot-repository&lt;/url&gt;
</span>            &lt;layout&gt;<span class="code-keyword">default</span>&lt;/layout&gt;
            &lt;snapshots&gt;
                &lt;enabled&gt;<span class="code-keyword">true</span>&lt;/enabled&gt;
                &lt;updatePolicy&gt;daily&lt;/updatePolicy&gt;
                &lt;checksumPolicy&gt;ignore&lt;/checksumPolicy&gt;
            &lt;/snapshots&gt;
            &lt;releases&gt;
                &lt;enabled&gt;<span class="code-keyword">false</span>&lt;/enabled&gt;
            &lt;/releases&gt;
        &lt;/pluginRepository&gt;
    &lt;/pluginRepositories &gt;
</pre>
</div></div>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Note on Geronimo Versions</b><br
/>Unless you are using a published archetype that goes with the version of geronimo you
are using, you will have to update the &lt;geronimoVersion&gt; property in the generated
poms to whatever the correct version is.  For instance as of writing the generated poms have
&lt;geronimoVersion&gt;2.2-SNAPSHOT&lt;/geronimoVersion&gt; and for use with
geronimo 2.1 you would update this to &lt;geronimoVersion&gt;2.1&lt;/geronimoVersion&gt;</td></tr></table></div>

<h2><a name="AssemblingaserverusingMaven-Repackagetheliferaywar"></a>Repackage
the liferay war</h2>
<p>The JEE spec tells us to package jars used by an application in with the application
in WEB-INF/lib or lib directories.  This may appear to make the application more self contained
but it can produce a tracking nightmare as it becomes more difficult to determine exactly
what is in these directories, what version is being used, etc etc, not to mention promoting
duplication of code used by several projects.  Geronimo instead lets you put your jars in
the maven-structured geronimo repository and specify the classloader structure for your apps
to include these jars where necessary.  If you want to convert an existing war project to
this repository-based classloader solution you probably need to remove some of the jars from
the existing war.  You can do this easily with maven war overlays.  For each jar you want
to use from the geronimo repository, you specify an exclude in the overlay configuration and
add the jar as a dependency in the maven project that builds the geronimo plugin.  This example
only excludes a few jars, most of which are already present in the parent classloader.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DarchetypeArtifactId=maven-archetype-webapp \
  -DarchetypeVersion=1.0 \
  -DgroupId=com.liferay \
  -DartifactId=liferay-portal-lesslibs \
  -Dversion=4.4.1-SNAPSHOT
cd liferay-portal-lesslibs
rm -rf src
</pre>
</div></div>

<p>Modify the pom.xml to include the liferay war dependency</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
        &lt;dependency&gt;
            &lt;groupId&gt;com.liferay&lt;/groupId&gt;
            &lt;artifactId&gt;liferay-portal&lt;/artifactId&gt;
            &lt;version&gt;4.4.1&lt;/version&gt;
            &lt;type&gt;war&lt;/type&gt;
	&lt;/dependency&gt;
</pre>
</div></div>

<p>and configure the war plugin with an overlay descriptor:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                &lt;version&gt;2.1-alpha-1&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;overlays&gt;
                        &lt;overlay&gt;
                            &lt;id&gt;liferay&lt;/id&gt;
                            &lt;groupId&gt;com.liferay&lt;/groupId&gt;
                            &lt;artifactId&gt;liferay-portal&lt;/artifactId&gt;
                            &lt;excludes&gt;
                                &lt;exclude&gt;WEB-INF/classes/log4j.properties&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/geronimo-web.xml&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/jboss-web.xml&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/jonas-web.xml&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/jrun-web.xml&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/resin-web.xml&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/sun-web.xml&lt;/exclude&gt;

                                &lt;!-- use geronimo dependencies rather than inclusion
<span class="code-keyword">for</span> published artifacts --&gt;
                                &lt;exclude&gt;WEB-INF/lib/activemq.jar&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/lib/commons-digester.jar&lt;/exclude&gt;
                                &lt;!-- other excludes are supplied by geronimo anyway
--&gt;
                                &lt;exclude&gt;WEB-INF/lib/cglib.jar&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/lib/commons-logging..jar&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/lib/j2ee-management.jar&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/lib/jmx-remote.jar&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/lib/jmx-ri.jar&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/lib/log4j.jar&lt;/exclude&gt;
                                &lt;exclude&gt;WEB-INF/lib/mx4j.jar&lt;/exclude&gt;
                            &lt;/excludes&gt;
                        &lt;/overlay&gt;
                    &lt;/overlays&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;

    &lt;/build&gt;
</pre>
</div></div>

<h2><a name="AssemblingaserverusingMaven-Buildadatabaseplugin"></a>Build
a database plugin</h2>

<p>in liferay-parent run</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn archetype:create \
  -DarchetypeGroupId=org.apache.geronimo.buildsupport \
  -DarchetypeArtifactId=geronimo-plugin-archetype \
  -DarchetypeVersion=2.2-SNAPSHOT \
  -DartifactId=liferay-derby
</pre>
</div></div>

<p>Change the plan so it looks like this:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;?xml version=<span class="code-quote">"1.0"</span> encoding=<span class="code-quote">"UTF-8"</span>?&gt;

&lt;connector xmlns=<span class="code-quote">"http:<span class="code-comment">//geronimo.apache.org/xml/ns/j2ee/connector-1.2"</span>&gt;
</span>    &lt;resourceadapter&gt;
        &lt;outbound-resourceadapter&gt;
            &lt;connection-definition&gt;
                &lt;connectionfactory-<span class="code-keyword">interface</span>&gt;javax.sql.DataSource&lt;/connectionfactory-<span
class="code-keyword">interface</span>&gt;
                &lt;connectiondefinition-instance&gt;
                    &lt;name&gt;jdbc/LiferayPool&lt;/name&gt;
                    &lt;config-property-setting name=<span class="code-quote">"Password"</span>&gt;liferay&lt;/config-property-setting&gt;
                    &lt;config-property-setting name=<span class="code-quote">"UserName"</span>&gt;liferay&lt;/config-property-setting&gt;
                    &lt;config-property-setting name=<span class="code-quote">"DatabaseName"</span>&gt;liferay&lt;/config-property-setting&gt;
                    &lt;connectionmanager&gt;
                        &lt;local-transaction/&gt;
                        &lt;single-pool&gt;
                            &lt;max-size&gt;10&lt;/max-size&gt;
                            &lt;min-size&gt;0&lt;/min-size&gt;
                            &lt;match-one/&gt;
                        &lt;/single-pool&gt;
                    &lt;/connectionmanager&gt;
                &lt;/connectiondefinition-instance&gt;
&lt;!-- Leave until we figure out <span class="code-keyword">if</span> non-jta
datasource is needed --&gt;
&lt;!--
                &lt;connectiondefinition-instance&gt;
                    &lt;name&gt;jdbc/NoTxrollerdb&lt;/name&gt;
                    &lt;config-property-setting name=<span class="code-quote">"Password"</span>&gt;roller&lt;/config-property-setting&gt;
                    &lt;config-property-setting name=<span class="code-quote">"UserName"</span>&gt;roller&lt;/config-property-setting&gt;
                    &lt;config-property-setting name=<span class="code-quote">"DatabaseName"</span>&gt;roller&lt;/config-property-setting&gt;
                    &lt;connectionmanager&gt;
                        &lt;no-transaction/&gt;
                        &lt;single-pool&gt;
                            &lt;max-size&gt;10&lt;/max-size&gt;
                            &lt;min-size&gt;0&lt;/min-size&gt;
                            &lt;match-one/&gt;
                        &lt;/single-pool&gt;
                    &lt;/connectionmanager&gt;
                &lt;/connectiondefinition-instance&gt;
--&gt;
            &lt;/connection-definition&gt;
        &lt;/outbound-resourceadapter&gt;
    &lt;/resourceadapter&gt;

&lt;/connector&gt;

</pre>
</div></div>

<p>and modify the pom setting the geronimoVersion to 2.1 and with</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    &lt;dependencies&gt;
        &lt;!-- <span class="code-keyword">if</span> you are deploying a jee
application, use scope provided --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.tranql&lt;/groupId&gt;
            &lt;artifactId&gt;tranql-connector-derby-embed-local&lt;/artifactId&gt;
            &lt;version&gt;1.4&lt;/version&gt;
            &lt;type&gt;rar&lt;/type&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;

        &lt;!-- other dependencies will normally end up as dependencies in the plan and
geronimo-plugin.xml --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.configs&lt;/groupId&gt;
            &lt;artifactId&gt;system-database&lt;/artifactId&gt;
            &lt;type&gt;car&lt;/type&gt;
            &lt;version&gt;${geronimoVersion}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;!-- include dependencies on all deployer modules needed, with scope provided
--&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.configs&lt;/groupId&gt;
            &lt;artifactId&gt;connector-deployer&lt;/artifactId&gt;
            &lt;type&gt;car&lt;/type&gt;
            &lt;version&gt;${geronimoVersion}&lt;/version&gt;
        &lt;/dependency&gt;

    &lt;/dependencies&gt;
</pre>
</div></div>

<p>and</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.geronimo.buildsupport&lt;/groupId&gt;
                &lt;artifactId&gt;car-maven-plugin&lt;/artifactId&gt;
                &lt;configuration&gt;
                    &lt;deploymentConfigs&gt;
                        &lt;!-- gbean deployer is <span class="code-keyword">default</span>.
 For jee apps include all deployers your app needs, see properties --&gt;
                        &lt;deploymentConfig&gt;${gbeanDeployer}&lt;/deploymentConfig&gt;
                        &lt;deploymentConfig&gt;${connectorDeployer}&lt;/deploymentConfig&gt;
                    &lt;/deploymentConfigs&gt;
                    &lt;!-- <span class="code-keyword">if</span> you are deploying
a jee app specify it here --&gt;
                    &lt;module&gt;
                        &lt;groupId&gt;org.tranql&lt;/groupId&gt;
                        &lt;artifactId&gt;tranql-connector-derby-embed-local&lt;/artifactId&gt;
                        &lt;type&gt;rar&lt;/type&gt;
                    &lt;/module&gt;
                    &lt;!-- Normally you can use the maven dependencies unaltered.  If
you need to specify <span class="code-keyword">import</span> scope
                     you can list the dependencies here as you want them in the plan.xml --&gt;
                    &lt;useMavenDependencies&gt;
                        &lt;value&gt;<span class="code-keyword">true</span>&lt;/value&gt;
                        &lt;includeVersion&gt;<span class="code-keyword">true</span>&lt;/includeVersion&gt;
                    &lt;/useMavenDependencies&gt;
                    &lt;!-- the instance sets up most of the optional geronimo-plugin.xml
content --&gt;
                    &lt;instance&gt;
                        &lt;plugin-artifact&gt;
                        &lt;/plugin-artifact&gt;
                    &lt;/instance&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;

</pre>
</div></div>


<h2><a name="AssemblingaserverusingMaven-Buildtheliferaywarplugin"></a>Build
the liferay war plugin</h2>

<p>run</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn archetype:create \
  -DarchetypeGroupId=org.apache.geronimo.buildsupport \
  -DarchetypeArtifactId=geronimo-plugin-archetype \
  -DarchetypeVersion=2.2-SNAPSHOT \
  -DartifactId=liferay-jetty
</pre>
</div></div>

<p>Edit the plan so it looks like:<br/>
NOTE: this is derived from the liferay plan at and is under the liferay (MIT) license</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;?xml version=<span class="code-quote">"1.0"</span>?&gt;

&lt;web-app xmlns=<span class="code-quote">"http:<span class="code-comment">//geronimo.apache.org/xml/ns/j2ee/web-2.0.1"</span>&gt;
</span>
    &lt;environment&gt;
        &lt;inverse-classloading/&gt;
    &lt;/environment&gt;

	&lt;context-root&gt;${LiferayContextPath}&lt;/context-root&gt;
	&lt;security-realm-name&gt;PortalRealm&lt;/security-realm-name&gt;
      &lt;security use-context-handler=<span class="code-quote">"<span class="code-keyword">false</span>"</span>
xmlns=<span class="code-quote">"http:<span class="code-comment">//geronimo.apache.org/xml/ns/security-2.0"</span>&gt;
</span>&lt;!-- requires security to be set up <span class="code-keyword">for</span>
<span class="code-keyword">default</span> subject
        &lt;<span class="code-keyword">default</span>-subject&gt;
          &lt;realm&gt;PortalRealm&lt;/realm&gt;
          &lt;id&gt;<span class="code-keyword">default</span>&lt;/id&gt;
        &lt;/<span class="code-keyword">default</span>-subject&gt;
--&gt;
        &lt;role-mappings&gt;
          &lt;role role-name=<span class="code-quote">"users"</span>&gt;
              &lt;principal class=<span class="code-quote">"com.liferay.portal.security.jaas.PortalRole"</span>
name=<span class="code-quote">"users"</span> /&gt;
          &lt;/role&gt;
        &lt;/role-mappings&gt;
      &lt;/security&gt;

    &lt;gbean name=<span class="code-quote">"CredentialStore"</span> class=<span
class="code-quote">"org.apache.geronimo.security.credentialstore.SimpleCredentialStoreImpl"</span>&gt;
        &lt;xml-attribute name=<span class="code-quote">"credentialStore"</span>&gt;
            &lt;credential-store xmlns=<span class="code-quote">"http:<span class="code-comment">//geronimo.apache.org/xml/ns/credentialstore-1.0"</span>&gt;
</span>                &lt;realm name=<span class="code-quote">"PortalRealm"</span>&gt;
                    &lt;subject&gt;
                        &lt;id&gt;<span class="code-keyword">default</span>&lt;/id&gt;
&lt;!-- you will have so set up the backing store appropriately --&gt;
                        &lt;credential&gt;
                            &lt;type&gt;org.apache.geronimo.security.credentialstore.NameCallbackHandler&lt;/type&gt;
                            &lt;value&gt;anonymous&lt;/value&gt;
                        &lt;/credential&gt;
                        &lt;credential&gt;
                            &lt;type&gt;org.apache.geronimo.security.credentialstore.PasswordCallbackHandler&lt;/type&gt;
                            &lt;value&gt;anonymous&lt;/value&gt;
                        &lt;/credential&gt;
                    &lt;/subject&gt;
                &lt;/realm&gt;
            &lt;/credential-store&gt;
        &lt;/xml-attribute&gt;
        &lt;dependency&gt;
            &lt;name&gt;PortalRealm&lt;/name&gt;
        &lt;/dependency&gt;
    &lt;/gbean&gt;



	&lt;gbean name=<span class="code-quote">"PortalRealm"</span> class=<span
class="code-quote">"org.apache.geronimo.security.realm.GenericSecurityRealm"</span>&gt;
		&lt;attribute name=<span class="code-quote">"realmName"</span>&gt;PortalRealm&lt;/attribute&gt;
		&lt;reference name=<span class="code-quote">"ServerInfo"</span>&gt;
			&lt;name&gt;ServerInfo&lt;/name&gt;
		&lt;/reference&gt;
		&lt;xml-reference name=<span class="code-quote">"LoginModuleConfiguration"</span>&gt;
			&lt;log:login-config xmlns:log=<span class="code-quote">"http:<span class="code-comment">//geronimo.apache.org/xml/ns/loginconfig-2.0"</span>&gt;
</span>				&lt;log:login-module control-flag=<span class="code-quote">"REQUIRED"</span>
wrap-principals=<span class="code-quote">"<span class="code-keyword">false</span>"</span>&gt;
					&lt;log:login-domain-name&gt;PortalDomain&lt;/log:login-domain-name&gt;
					&lt;log:login-module-class&gt;com.liferay.portal.security.jaas.ext.tomcat.PortalLoginModule&lt;/log:login-module-class&gt;
				&lt;/log:login-module&gt;
			&lt;/log:login-config&gt;
		&lt;/xml-reference&gt;
	&lt;/gbean&gt;
&lt;/web-app&gt;
</pre>
</div></div>

<p>and the pom to have geronimoVersion 2.1, liferayVersion 4.4.1 and include</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    &lt;dependencies&gt;
        &lt;!-- <span class="code-keyword">if</span> you are deploying a jee
application, use scope provided --&gt;
        &lt;!-- other dependencies will normally end up as dependencies in the plan and
geronimo-plugin.xml --&gt;
        &lt;!-- include dependencies on all deployer modules needed, with scope provided
--&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;com.liferay&lt;/groupId&gt;
            &lt;artifactId&gt;liferay-portal-lesslibs&lt;/artifactId&gt;
            &lt;version&gt;${liferayVersion}-SNAPSHOT&lt;/version&gt;
            &lt;type&gt;war&lt;/type&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
	&lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.configs&lt;/groupId&gt;
            &lt;artifactId&gt;javamail&lt;/artifactId&gt;
            &lt;type&gt;car&lt;/type&gt;
            &lt;version&gt;${geronimoVersion}&lt;/version&gt;
        &lt;/dependency&gt;
&lt;!-- replaces activemq jar in lib dir --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
            &lt;artifactId&gt;activemq-core&lt;/artifactId&gt;
            &lt;type&gt;jar&lt;/type&gt;
            &lt;version&gt;4.1.1&lt;/version&gt;
        &lt;/dependency&gt;
&lt;!-- activemq car does not work because liferay wants to use spring to configure activemq.
If we can eliminate the spring 
files in portal-impl.jar perhaps <span class="code-keyword">this</span> would
work.
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.configs&lt;/groupId&gt;
            &lt;artifactId&gt;activemq-ra&lt;/artifactId&gt;
            &lt;type&gt;car&lt;/type&gt;
            &lt;version&gt;${geronimoVersion}&lt;/version&gt;
        &lt;/dependency&gt;
--&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;liferay-derby&lt;/artifactId&gt;
            &lt;type&gt;car&lt;/type&gt;
            &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;portlet-api&lt;/groupId&gt;
            &lt;artifactId&gt;portlet-api&lt;/artifactId&gt;
            &lt;version&gt;1.0&lt;/version&gt;
	&lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.liferay&lt;/groupId&gt;
            &lt;artifactId&gt;portal-kernel&lt;/artifactId&gt;
            &lt;version&gt;${liferayVersion}&lt;/version&gt;
	&lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.liferay&lt;/groupId&gt;
            &lt;artifactId&gt;portal-service&lt;/artifactId&gt;
            &lt;version&gt;${liferayVersion}&lt;/version&gt;
	&lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;xerces&lt;/groupId&gt;
            &lt;artifactId&gt;xercesImpl&lt;/artifactId&gt;
            &lt;version&gt;2.8.1&lt;/version&gt;
	&lt;/dependency&gt;

       &lt;dependency&gt;
            &lt;groupId&gt;saxpath&lt;/groupId&gt;
            &lt;artifactId&gt;saxpath&lt;/artifactId&gt;
            &lt;version&gt;1.0-FCS&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;commons-digester&lt;/groupId&gt;
            &lt;artifactId&gt;commons-digester&lt;/artifactId&gt;
            &lt;version&gt;1.8&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.framework&lt;/groupId&gt;
            &lt;artifactId&gt;geronimo-gbean-deployer&lt;/artifactId&gt;
            &lt;type&gt;car&lt;/type&gt;
            &lt;version&gt;${geronimoVersion}&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.configs&lt;/groupId&gt;
            &lt;artifactId&gt;jetty6-deployer&lt;/artifactId&gt;
            &lt;type&gt;car&lt;/type&gt;
            &lt;version&gt;${geronimoVersion}&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.configs&lt;/groupId&gt;
            &lt;artifactId&gt;jasper-deployer&lt;/artifactId&gt;
            &lt;type&gt;car&lt;/type&gt;
            &lt;version&gt;${geronimoVersion}&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.configs&lt;/groupId&gt;
            &lt;artifactId&gt;persistence-jpa10-deployer&lt;/artifactId&gt;
            &lt;type&gt;car&lt;/type&gt;
            &lt;version&gt;${geronimoVersion}&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;

    &lt;/dependencies&gt;
</pre>
</div></div>

<p>and </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.geronimo.buildsupport&lt;/groupId&gt;
                &lt;artifactId&gt;car-maven-plugin&lt;/artifactId&gt;
                &lt;configuration&gt;
                    &lt;deploymentConfigs&gt;
                        &lt;!-- gbean deployer is <span class="code-keyword">default</span>.
 For jee apps include all deployers your app needs, see properties --&gt;
                        &lt;deploymentConfig&gt;${gbeanDeployer}&lt;/deploymentConfig&gt;
                        &lt;deploymentConfig&gt;${j2eeDeployer}&lt;/deploymentConfig&gt;
                        &lt;deploymentConfig&gt;${jetty6Deployer}&lt;/deploymentConfig&gt;
                        &lt;deploymentConfig&gt;${jasperDeployer}&lt;/deploymentConfig&gt;
                        &lt;!--&lt;deploymentConfig&gt;${jpaDeployer}&lt;/deploymentConfig&gt;--&gt;
                    &lt;/deploymentConfigs&gt;
                    &lt;!-- <span class="code-keyword">if</span> you are deploying
a jee app specify it here --&gt;

                                        &lt;module&gt;
            &lt;groupId&gt;com.liferay&lt;/groupId&gt;
            &lt;artifactId&gt;liferay-portal-lesslibs&lt;/artifactId&gt;
            &lt;version&gt;${liferayVersion}&lt;/version&gt;
            &lt;type&gt;war&lt;/type&gt;
                                        &lt;/module&gt;

                    &lt;!-- Normally you can use the maven dependencies unaltered. If
you need to specify <span class="code-keyword">import</span> scope
                     you can list the dependencies here as you want them in the plan.xml --&gt;
                    &lt;useMavenDependencies&gt;
                        &lt;value&gt;<span class="code-keyword">true</span>&lt;/value&gt;
                        &lt;includeVersion&gt;<span class="code-keyword">true</span>&lt;/includeVersion&gt;
                    &lt;/useMavenDependencies&gt;
                    &lt;!-- the instance sets up most of the optional geronimo-plugin.xml
content --&gt;
                    &lt;instance&gt;
                        &lt;plugin-artifact&gt;
                            &lt;!-- extract stuff from the car to the specified location
(good <span class="code-keyword">for</span> config info --&gt;
                            &lt;!--&lt;copy-file relative-to=<span class="code-quote">"server"</span>
dest-dir=<span class="code-quote">"<span class="code-keyword">var</span>/roller-data"</span>&gt;themes&lt;/copy-file&gt;--&gt;
                            &lt;!-- content that should go into <span class="code-keyword">var</span>/config/config.xml
<span class="code-keyword">for</span> module customization --&gt;
                            &lt;!-- note the variable ${LiferayContextPath} which is further
specified in <span class="code-keyword">var</span>/config/config-substitutions.properties
--&gt;

                                                        &lt;config-xml-content server=<span
class="code-quote">"<span class="code-keyword">default</span>"</span>&gt;
                                                            &lt;gbean name=<span class="code-quote">"org.apache.geronimo.plugins/liferay-jetty/${liferayPluginVersion}/car"</span>&gt;
                                                                &lt;attribute name=<span
class="code-quote">"contextPath"</span>&gt;${LiferayContextPath}&lt;/attribute&gt;
                                                            &lt;/gbean&gt;
                                                        &lt;/config-xml-content&gt;

                            &lt;!-- a user-tweakable variable to go into <span class="code-keyword">var</span>/config/config-substitutions.properties
--&gt;
                            &lt;config-substitution key=<span class="code-quote">"LiferayContextPath"</span>&gt;/liferay&lt;/config-substitution&gt;
                        &lt;/plugin-artifact&gt;
                    &lt;/instance&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;

</pre>
</div></div>

<h2><a name="AssemblingaserverusingMaven-Buildanassembly"></a>Build an assembly</h2>
<p>In liferay-parent run</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn archetype:create \
  -DarchetypeGroupId=org.apache.geronimo.buildsupport \
  -DarchetypeArtifactId=geronimo-assembly-archetype \
  -DarchetypeVersion=2.2-SNAPSHOT \
  -DgroupId=org.apache.geronimo.plugins \
  -DartifactId=geronimo-jetty-liferay \
  -Dversion=1.0-SNAPSHOT
</pre>
</div></div>

<p>Edit the geronimo-jetty-liferay pom to set geronimoVersion to 2.1 and include the
top level modules you want in your server (console-jetty is optional)</p>

<p>NOTE: do not remove the boilerplate!</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
        &lt;!-- List the plugins you want in your server --&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;liferay-jetty&lt;/artifactId&gt;
            &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
            &lt;type&gt;car&lt;/type&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.geronimo.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;console-jetty&lt;/artifactId&gt;
            &lt;version&gt;${geronimoVersion}&lt;/version&gt;
            &lt;type&gt;car&lt;/type&gt;
        &lt;/dependency&gt;

</pre>
</div></div>

<h2><a name="AssemblingaserverusingMaven-Runtheproject%21"></a>Run the project!</h2>
<p>The maven project is now complete. Run it and try out the resulting server!</p>

<p>in liferay-parent run</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn clean install
</pre>
</div></div>

<p>To try out the resulting server you can find it in your local maven repo under .m2/repository/org/apache/geronimo/plugins/geronimo-jetty-liferay/1.0-SNAPSHOT/geronimo-jetty-liferay-1.0-SNAPSHOT-bin.tar.gz
or in the build in geronimo-jetty-liferay/target.</p>

<p>Untar and run with </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
cd geronimo-jetty-liferay/target
tar xzf geronimo-jetty-liferay-1.0-SNAPSHOT-bin.tar.gz
cd geronimo-jetty-liferay-1.0-SNAPSHOT
#edit etc/rc.d/start-server,<span class="code-keyword">default</span>.groovy
#insert line 
#command.javaFlags &lt;&lt; '-XX:MaxPermSize=1024m'
#and update -Xmx1024m
./bin/gsh geronimo/start-server
</pre>
</div></div>

<p>As of writing the server will start but accessing <a href="http://localhost:8080/liferay"
class="external-link" rel="nofollow">http://localhost:8080/liferay</a> redirects
to <a href="http://localhost:8080/c" class="external-link" rel="nofollow">http://localhost:8080/c</a>
and gives a 404 error.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/Assembling+a+server+using+Maven">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=20645311&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/GMOxDOC30/Assembling+a+server+using+Maven?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message