<?xml version="1.0"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  -->
<document>
    <properties>
        <title>Welcome to Jackrabbit Deployment Test</title>
    </properties>
    <body>
        <section name="About Jackrabbit Deployment Test">
            <p>
                As described in the Jackrabbit documentation, there are three deployment models:
                <ul>
                    <li><a href="http://jackrabbit.apache.org/doc/deploy/howto-model1.html">Model 1 (Embedded)</a>
                     - Embed the Jackrabbit repository in your webapp. This gives your app full
                     responsibility for managing the repository, and does not allow other webapps
                     to use it.</li>
                    <li><a href="http://jackrabbit.apache.org/doc/deploy/howto-model2.html">Model 2 (Shared)</a>
                    - Share a repository with all webapps in the application server. This provides
                    a repository managed by the application server that is accessible by all webapps
                    in the server.</li>
                    <li><a href="http://jackrabbit.apache.org/doc/deploy/howto-model3.html">Model 3 (Server)</a>
                    - Run the repository as a stand-alone server, or on an external application
                    server. The repository is accessed using JCR-RMI or WebDAV.</li>
                </ul>
                This project provides guidance and an example deployment for Model 1 and Model 2
                using Tomcat 5.5.x.
            </p>
            <p>
                If you run the webapp, it will attempt to access both an Embedded (Model 1)
                repository and a Shared (Model 2) repository. For each repository it is able to
                access through JNDI, it tries to log into the repository and create a single test
                node. It then prints the contents of that node to the HTML output of the servlet.
                Along the way, it prints status information and any exceptions thrown that may be
                helpful in debugging configuration issues.
            </p>
            <p>
                Follow the instructions on this page to first configure Tomcat and the repositories
                and then build and install the webapp itself.
            </p>
        </section>
        <section name="Configuring Tomcat (5.5.x)">
            <p>
                Before getting started, you will need to do some configuration to Tomcat itself.
                This webapp uses both repositories, one embedded and one shared. This is important
                to note because where you put the jar files for Jackrabbit and its dependencies
                can change depending on which model you use.
            </p>
            <subsection name="Jackrabbit JAR locations">
                <p>
                    If your webapp is using an embedded repository only, you can place the jars for
                    Jackrabbit and its dependencies in your <code>WEB-INF/lib/</code> directory. If
                    your webapp is using a shared repository, the jars should be placed in the
                    application server's common JAR library; for Tomcat that location is
                    <code>$CATALINA_HOME/common/lib/</code>.
                </p>
            </subsection>
            <subsection name="Logging">
                <p>
                    You should configure Log4J so that Jackrabbit can report errors and other
                    status information. The configuration should go in the
                    <code>$CATALINA_HOME/common/class/log4j.properties</code> file. Here is a sample
                    Log4J configuration, which only specifies logging parameters for Jackrabbit and
                    JCR.
                </p>
                <source><![CDATA[
# Use the INFO logging level for stdout.
log4j.rootCategory=INFO

# Output pattern (shared)
# date priority [category] - <message>line_separator

# STDOUT properties
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

log4j.logger.org.apache.jackrabbit=ALL, stdout
log4j.logger.javax.jcr=ALL, stdout
]]></source>
                <p>
                    This configuration will log as much information as possible to the main
                    Tomcat log file, <code>$CATALINA_HOME/logs/catalina.out</code>. You can reduce
                    the amount of information by changing the logging level from <code>ALL</code>
                    to <code>DEBUG</code>, <code>INFO</code>, <code>WARN</code>,
                    <code>ERROR</code>, or <code>FATAL</code> (there may be very little difference
                    between <code>ALL</code> and <code>DEBUG</code>). While you are developing your
                    webapp, you may find it useful to keep the Jackrabbit logging somewhere
                    between <code>ALL</code> and <code>INFO</code> so you can watch it process
                    calls you make to the repository.
                </p>
            </subsection>
            <subsection name="JAAS Security">
                <p>
                    In order for the webapp to login to the repository, you need to configure
                    JAAS. Fortunately, the Jackrabbit project comes with a login module that
                    allows minimal setup. The example <code>jaas.config</code> configuration is
                    included at the root of the web application's source directory; it should be
                    copied to <code>$CATALINA_HOME/conf/jaas.config</code>. If you already have
                    a JAAS configuration file for your Tomcat installation, you should merge the
                    settings below.
                </p>
                <source><![CDATA[
Jackrabbit {
    org.apache.jackrabbit.core.security.SimpleLoginModule required;
};
]]></source>
                <p>
                    Now you should set the <code>JAVA_OPTS</code> environment variable to the
                    following value so Tomcat knows where to find the configuration file.
                </p>
                <source><![CDATA[
-Djava.security.auth.login.config=$CATALINA_HOME/conf/jaas.config
]]></source>
                <p>
                    Make sure you start Tomcat from the environment where <code>JAVA_OPTS</code>
                    has been set. If the Tomcat starts without JAAS configured properly, when
                    you run the webapp, it will report a <code>LoginException</code> for each
                    repository that is configured and accessible.
                </p>
            </subsection>
        </section>
        <section name="Configuring the repositories">
            <p>
                This webapp contains a sample repository configuration for the Embedded (Model 1)
                repository in <code>META-INF/repository_model1.xml</code>. The configuration for
                the Shared (Model 2) repository is at the root level of the web application's
                source directory; it should be copied to
                <code>$CATALINA_HOME/conf/repository_model2.xml</code>.
            </p>
            <p>
                For details on the repository configuration file, see the
                <a href="http://jackrabbit.apache.org/doc/firststeps.html">First Hops</a>
                tutorial.
            </p>
        </section>
        <section name="Building this webapp">
            <p>
                Before you build the webapp, you should follow the
                <a href="http://jackrabbit.apache.org/doc/building.html">build
                instructions</a> on the main Jackrabbit website to build the
                <code>jackrabbit-1.0-SNAPSHOT.jar</code>. To build the webapp, you will need to use
                Maven's <code>war</code> goal.
            </p>
                <source><![CDATA[
user$ maven war
]]></source>
            <p>
                Once the webapp is built, you should copy the
                <code>target/jackrabbit_deployment_test.war</code> file to
                <code>$CATALINA_HOME/webapps/</code> and then start Tomcat. You should then be able
                to run the servlet by clicking on the link in the application's
                <a href="http://localhost:8080/jackrabbit_deployment_test/index.html">welcome
                page</a>.
            </p>
        </section>
    </body>
</document>
