cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Created: Environment Configuration FAQs
Date Wed, 21 Sep 2005 15:00:34 GMT
A new document has been created.

Document ID: 713
Branch: main
Language: default
Name: Environment Configuration FAQs
Document Type: Document
Created: 9/21/05 3:00:22 PM
Creator (owner): Helma van der Linden
State: publish


Mime type: text/xml
Size: 7415 bytes

<h2>How can I reach my Cocoon app from an URI other than

<p>Suppose the following.</p>

<li>You have a Cocoon application named "bar" which works fine when called with
this URI:</li>
<li>You want the "bar" app to be called from
instead (getting rid of "cocoon").</li>

<p>There are, basically, two methods to achieve this.</p>

<li>Set Cocoon as the root servlet in your servlet-container</li>
<li>Rewrite the URI in the web-server. (When a user asks for, the web-server redirects him/her to</li>

<p>Let us explore the first method (Cocoon as the root servlet).</p>

<p class="note">This entry was tested under: Windows 2000 Professional + IIS 5.0
+ Tomcat 4.0.1 + Cocoon 2.0.2.</p>

<li>Edit the server.xml file which is located under $TOMCAT_HOME/conf</li>
<li>Go to the line containing "Tomcat Root Context". (This should be a comment).
<li>Add following line after that comment: &lt;context path="" docBase="/cocoon"
<li>Re-start Tomcat.</li>
<li>Try: and the Cocoon welcome page should appear

<p>Now, should also work.</p>

<p>Let us explore the second method (URI rewriting).</p>

<p class="note">This entry was tested under: Windows NT 4.0 + Apache 1.3.14 +
Tomcat 3.2 + Cocoon 2.0b1. It is Apache-specific.</p>

<p>The idea is just to redirect a portion of the desired URI (bar) to the one
within the cocoon context (cocoon/bar).</p>

<p>Apache has an handy feature called mod_rewrite that does just this: URI
rewriting. (See the "URL Rewriting Guide" in the Apache user's guide for

<p>First of all, you should instruct Apache to load the mod_rewrite. Add (on a
Windows system) to httpd.conf the following line:</p>

<p>LoadModule rewrite_module modules/ApacheModuleRewrite.dll</p>

<p>(By the way it's quite likely that this line is already on the httpd.conf.
You just have to uncomment it).</p>

<p>Add this line to httpd.conf in order to activate mod_rewrite:</p>

<p>RewriteEngine On</p>

<p>It is highly recommended to use the logging option of mod_rewrite, in order
to check the correctness of the URI rewriting. Just add these lines to the

<p>RewriteLog "C:/logs/rewrite.log" RewriteLogLevel 9</p>

<p>The first line tells Apache to put the URI rewriting log in the
c:\logs\rewrite.log file (which happens to be on a Windows system, of course).
The second one tells Apache to record everything mod_rewrite does. If you don't
want to log anything, just set RewriteLogLevel to 0.</p>

<p>Now, it's time to do the URI rewriting trick.</p>

<p>RewriteRule bar/(.*) /cocoon/bar/$1 [PT]</p>

<p>This line instructs Apache to redirect everything under "bar" to "cocoon/bar"
and to pass it on for other processing ("[PT]" option), like mod_alias.</p>

<p>Just restart Apache and point your browser to:</p>


<p>It should work just fine.</p>

<p class="note">The RewriteRule may not work in all cases (notably under
Slackware Linux with Apache 1.3), if so, try replacing it with: RewriteRule
^/Foo /cocoon/Foo/ [R] RewriteRule ^/Foo(.*) /cocoon/Foo$1 [R]</p>

<p class="note">Another user adds: In my experience, session support is lost
when you use mod_rewrite because the cookie path for the Cocoon session is
"/cocoon". Because the browser sees the path differently, the session cookie is
not granted access, and sessions don't work. I got around this by renaming
Cocoon to ROOT, I imagine setting the default docBase would have the same

<h2>How could I have my Cocoon app located in a directory other than

<p class="note">This entry was tested under Windows NT 4.0 + Apache 1.3.14 +
Tomcat 3.2 + Cocoon 2.0b1.</p>

<p>Let's suppose the following.</p>

<li>You have an application called "foo" which works perfectly when located
under the %TOMCAT_HOME%\webapps\cocoon\foo directory.</li>
<li>You want it to be located under the "c:\foo" directory instead</li>

<p>This could be accomplished quite easily by twisting the sitemap a little bit.
The idea is to mount the sub-sitemap of the "foo" application in a specific
location of the file system instead of under the default cocoon context.</p>

<p>Here's the sitemap.xmap fragment used to do this.</p>

<p>The "file:" type of source instructs Cocoon to search the sub-sitemap under
the specified directory (which happens to be "c:\foo", since this is a Windows
system). See explanation of file: URLs</p>

<p>Now, you just need to copy everything which was under the
%TOMCAT_HOME%\webapps\cocoon\foo directory to the c:\foo directory, and it
should work graciously.</p>

<h2>How do I integrate Apache Server and Cocoon?</h2>

<p>See the Wiki page ApacheModProxy for a thorough discussion of this topic.

<p>Another method is to use mod_jk. Add the following line to

<p>JkMount /cocoon/* ajp12</p>

<p>along with other directives that are already listed in mod_jk.conf-auto in
the tomcat/conf directory. The above directives can be added at the end of

<h2>How can I improve performance by making the web-server deliver the static
contents ?</h2>

<p>Fairly easy to do.</p>

<li>Put the static contents in a physical directory. (Let's call it
"c:\foo\static-stuff". On UNIX it may be "/foo/static-stuff".)</li>
<li>Make a virtual directory out of "c:\foo\static-stuff" (or, under UNIX
"/foo/static-stuff") in you favorite web-server, and name it "static-foo".</li>
<li>Reference the static contents in your Cocoon app by URIs starting with
"/static-foo", as in: "/static-foo/images/foo.gif" or

<p>The web-server will now handle the static contents, leaving Cocoon to take
care of the dynamic stuff only, delivering optimal performance.</p>

<h2>Why won't my Batik .JPG and .PNG samples work? How can I run Cocoon without
X11? Why is a Display needed?</h2>

<p>If your Batik .JPG and .PNG samples don't work it is probably because you
have not installed and configured a graphics display. You have a couple of
options depending on your environment.</p>

<p>If you are using the Sun JDK 1.4 then you can use the 'headless' environment.
For more information about this see Headless UNIX and PJA.</p>

<p>Otherwise, an XServer is needed because of the Batik library that FOP uses.
Batik uses Java's graphics code, which in turn requires the XServer. If you
don't have an XServer on your system and can't set the DISPLAY variable to one,
then try out XVFB. XVFB gives you an 'in-memory' XServer, which doesn't require
any display hardware to run.</p>

<pre>$&gt; Xvfb :1 -screen 0 800x600x8 &amp;
$&gt; export DISPLAY=:1
$&gt; $TOMCAT_HOME/bin/ -f server.xml

<p>See also UNIX with X server</p>

<h2>How can I access Cocoon's status page in a mixed servlet environment where
"/" is not mapped to Cocoon (only *.xml, *.xsp)?</h2>

<p>Just change the status pipeline so it matches a request with a ".xml"


<p>Then you can access the status page with "status.xml".</p>


The document belongs to the following collections: legacydocs

View raw message