Installing Apache Archiva as a Web Application

Archiva can be deployed as a web application into any Java EE application server. This document will show an example of doing so with Tomcat 5.5 and Tomcat 6.0.x.

Note: When you first start Archiva, you will see an Exception that schema SA does not exist - however it doesn't cause a problem. If you use a username other than 'sa', such as 'archiva', then you seem to get the same error but Tomcat fails to start the context and you have to shutdown and restart again.

To deploy Archiva on Tomcat 5.5

  • Create a directory in tomcat called archiva, at the same level as bin, conf, logs and the others.
  • Copy the war file into the new directory
  • Create a conf/Catalina/localhost/archiva.xml file with the following data (replace the database paths with a suitable location):
     <?xml version="1.0" encoding="UTF-8"?>
     <Context path="/archiva"
              docBase="${catalina.home}/archiva/archiva-webapp-1.0.war">
    
     <Resource name="jdbc/users" auth="Container" type="javax.sql.DataSource"
               username="sa"
               password=""
               driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
               url="jdbc:derby:/path/to/database/archiva;create=true" />
    
     <Resource name="jdbc/archiva" auth="Container" type="javax.sql.DataSource"
               username="sa"
               password=""
               driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
               url="jdbc:derby:/path/to/database/archiva;create=true" />
    
     <Resource name="mail/Session" auth="Container"
                type="javax.mail.Session"
                mail.smtp.host="localhost"/>
     </Context>
  • Install derby-10.1.3.1.jar and mail-1.4.jar into the Tomcat common/lib. This is required since the data sources are instantiated before the web application.

    Note: Tomcat 5.5.20 and 5.5.23 are missing MailSessionFactory and a few other classes. JNDI mail sessions will not work. Use Tomcat 5.5.17 instead, or see Bug 40668 for a workaround.

To deploy Archiva on Tomcat 6.0.x:

  • Do the same steps specified above when deploying to Tomcat 5.5.
  • The $appserver.base java property is used by the Archiva internal logging configuration to determine where to output its logs to. It is important to define this property either in the $CATALINA_OPTS system environment variable (if Tomcat is being launched via the command line) or the service properties (if being launched as a service or daemon). The format typically expected is -Dappserver.base=SOMEWHERE. In this example, we'll put the logs in Tomcat's logs directory so we need to set appserver.base property to where Tomcat is installed:
    export CATALINA_OPTS="-Dappserver.home=$CATALINA_HOME -Dappserver.base=$CATALINA_HOME"

Archiva Configuration

Archiva is configured using the ~/.m2/archiva.xml configuration file by default when using a Java EE application server.

Upgrading Archiva

To upgrade the Archiva web application, simply replace the web application with an alternative. Since the database and configuration files are stored externally to the application, no further maintainance is needed.

For general information about upgrading Archiva, see the relevant section in the Installing standalone guide.

Configuring and Running Archiva

Once Archiva is running, it is configured in the same way as the standalone instance. See the quick start guide for more information.