cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Created: Deploying a Cocoon application
Date Sat, 05 May 2007 12:52:27 GMT
A new document has been created.

Document ID: 1362
Branch: main
Language: default
Name: Deploying a Cocoon application
Document Type: Cocoon Document
Created: 5/5/07 12:52:21 PM
Creator (owner): Reinhard Pötz
State: publish


Mime type: text/xml
Size: 5495 bytes

<p>In this tutorial, you will:</p>

<li>Connect the block to the webapp and run it</li>
<li>Create a parent Maven POM for the webapp and block (a convenience which
allows you to trigger cascading builds of both maven modules from a single
<li>Change the block mount point so that it is mounted at the root level context
(typical for a web application "main block")</li>

<h1>Creating a Cocoon web application</h1>

<p>First, make sure that you have Maven 2.0.6 or above installed. You can check
this by calling</p>

<pre>mvn --version</pre>

<p>from command line. If this doesn't work for you, read the
<a href="">Maven
in 5 Minutes</a> tutorial.</p>

<p>Next create a new directory which will be the root directory of your Cocoon
application. For this tutorial, let's name it <tt>getting-started-app</tt>.
Change into it and invoke the <tt>cocoon-22-archetype-webapp</tt> archetype:</p>

<pre>mvn archetype:create

<p class="note">For copy and paste without line feeds:<br/>
<tt>mvn archetype:create -DarchetypeGroupId=org.apache.cocoon
-DarchetypeArtifactId=cocoon-22-archetype-webapp -DarchetypeVersion=1.0.0-M2
-DgroupId=com.mycompany -DartifactId=</tt><tt>myCocoonWebapp</tt></p>

<h1>Using a block within the web application</h1>

<p>So far the web application <tt>myCocoonWebapp</tt> doesn't have any
information about the existense of the block <tt>myBlock1</tt> and
<tt>myBlock2</tt>. Change this by opening
<tt>getting-started-app/myCocoonWebapp/pom.xml</tt> and add the block as

<strong>        &lt;groupId&gt;<strong><tt>com.mycompany</tt></strong>&lt;/groupId&gt;
<strong>        &lt;groupId&gt;<strong><tt>com.mycompany</tt></strong>&lt;/groupId&gt;

<p>That's it. Now it's time to run the web application. Move into
<tt>getting-started-app/myCocoonWebapp</tt> and call</p>

<pre>mvn package jetty:run</pre>

<p>from there.<br/>
Open your favorite web browser and call</p>


<p>That's it!</p>

<h1>Creating a parent pom</h1>

<p>For your convenience you can create a parent pom for the two Maven modules.
Create a file <tt>getting-started-app/pom.xml</tt> with following content:</p>

<pre>&lt;project xmlns="" 

  &lt;name&gt;Cocoon Getting Stared application [parent]&lt;/name&gt;

<p>Having a parent pom file, you can trigger a reactor build from root, e.g. you
can call mvn install from root which will compile, package and install the
webapp and the block. Maven also takes care that the modules are build,
according to the dependency graph, in the correct order.</p>

<p>If you want to inherit information (e.g. plugin configurations, properties,
etc.) from the new parent pom to the two modules, you have to add the parent
element to <tt>getting-started-app/myCocoonWebapp/pom.xml</tt> and

<pre>&lt;project xmlns="" 

<strong>  &lt;parent&gt;


<h1>Mounting your block at the root level</h1>

<p>You can mount your block at the root level in the application URI space, so
that instead of using (for example) the URI
<tt>http://localhost:8888/myBlock/foo/bar</tt> to request a page, you would
request it at <tt>http://localhost:8888/foo/bar</tt>.</p>

<p>To do this, edit myBlock/src/main/resources/META-INF/cocoon/spring/block.xml
, and change the element</p>

<pre>    &lt;property name="mountPath" value="/myBlock1"/&gt;


<pre>    &lt;property name="mountPath" value=""/&gt;

<p>and then do <tt>mvn:install</tt>.</p>

<h1>Conclusion and further information</h1>

<p class="fixme">TBD</p>


The document belongs to the following collections: documentation, cdocs-site-main

View raw message