Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Archiva on JBoss

Archiva on JBoss 4.0.5

Warning

With release 1.4* the data source archiva is not anymore needed

Note

This information may be out of date. See Archiva on Tomcat or the instructions below for more required data sources.

Note

See also this blog post: Installing Apache Archiva on JBoss 4.2.3.GA.

Note

See also this thread on Nabble for more up to date information.

With the 'default' JBoss configuration:

1. copy archiva-webapp/src/main/webapp/WEB-INF/lib/derby-10.1.3.1.jar
into $JBOSS_HOME/server/default/lib;

2. create $JBOSS_HOME/server/default/deploy/derby-ds.xml

No Format
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
     <!-- The jndi name of the DataSource, it is prefixed with java:/ -->
     <!-- Datasources are not available outside the virtual machine -->
     <jndi-name>users</jndi-name>
     <!-- for in-process persistent db, saved when jboss stops. The
     org.jboss.jdbc.DerbyDatabase mbean is necessary for properly db shutdown -->
     <connection-url>jdbc:derby:database/archiva;create=true</connection-url>
     <!-- The driver class -->
     <driver-class>org.apache.derby.jdbc.EmbeddedDriver</driver-class>
     <!-- The login and password -->
     <user-name>sa</user-name>
     <password></password>
     <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
     <min-pool-size>5</min-pool-size>
     <!-- The maximum connections in a pool/sub-pool -->
     <max-pool-size>20</max-pool-size>
     <!-- The time before an unused connection is destroyed -->
     <idle-timeout-minutes>5</idle-timeout-minutes>
     <!-- Whether to check all statements are closed when the connection is returned to the pool,
          this is a debugging feature that should be turned off in production -->
     <track-statements/>
  </local-tx-datasource>
</datasources>

3. edit archiva-webapp/src/main/webapp/WEB-INF/web.xml and add

No Format
<resource-ref>
 <res-ref-name>jdbc/users</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
</resource-ref>

(somewhere between <web-app> and </web-app>);

4. create archiva-webapp/src/main/webapp/WEB-INF/jboss-web.xml

No Format
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
 <resource-ref>
   <res-ref-name>jdbc/users</res-ref-name>
   <jndi-name>java:/users</jndi-name>
 </resource-ref>
</jboss-web>

5. rerun 'mvn install' (to update the WAR with the updated web.xml and jboss-web.xml);

6. deploy the new WAR and Archiva should work.

Archiva 1.1.x on JBoss 4.2.x with an external datasource (tested with 1.1.3 on 4.2.2.GA)

While it is possible to use Archiva with the packaged Derby database it is often preferable to use an existing external RDBMS because it will integrate Archiva better into existing backup and maintenance processes. For the same reason it may be preferable to use your existing JBoss installation instead of Jetty supplied with the standalone installation. This tutorial will show you how this can be done.

  1. Connect to the database and create a user archiva and two schemas (or databases). In this example they are called archiva and archiva_users. Make sure the archiva user has appropriate rights to create tables on those schemas.
  2. Copy the JDBC driver (the jar file) for your databaseto <JBOSS_HOME>/server/default/lib. <JBOSS_HOME> is the directory where your JBoss is installed. (I assume throughout this text you are running the default instance because otherwise you would probably not bother to read this tutorial.)
  3. Create a file called archiva-ds.xml in <JBOSS_HOME>/server/default/deploy:
    No Format
    <?xml version="1.0" encoding="UTF-8"?>
    <datasources>
      <local-tx-datasource>
        <jndi-name>/jdbc/archiva</jndi-name>
        <connection-url>jdbc:postgresql://database.mycompany.com/archiva</connection-url>
        <driver-class>org.postgresql.Driver</driver-class>
        <user-name>archiva</user-name>
        <password>archiva</password>
        <min-pool-size>5</min-pool-size>
        <max-pool-size>20</max-pool-size>
        <idle-timeout-minutes>0</idle-timeout-minutes>
        <track-statements/>
      </local-tx-datasource>
    
      <local-tx-datasource>
        <jndi-name>/jdbc/archiva_users</jndi-name>
        <connection-url>jdbc:postgresql://database.mycompany.com/archiva_users</connection-url>
        <driver-class>org.postgresql.Driver</driver-class>
        <user-name>archiva</user-name>
        <password>archiva</password>
        <min-pool-size>5</min-pool-size>
        <max-pool-size>20</max-pool-size>
        <idle-timeout-minutes>0</idle-timeout-minutes>
        <track-statements/>
      </local-tx-datasource>
    </datasources>
    
    This example uses postgresql. If you use a different database you must alter the connection string and the driver class. For more infomation on setting up datasources take a look at the JBoss Wiki.
  4. To enable email you must verify that the mail settings in <JBOSS_HOME>/server/default/deploy-mail-service.xml are correct. Again the JBoss Wiki may be helpful.
  5. Create a directory <JBOSS_HOME>/server/default/deploy/archiva.war
  6. Download the Archiva war distribution and unzip the contents of that file to the archive created above.
  7. By default archiva uses its own logging mechanism. It is preferable to redirect logging output to the application server. To do so delete the following files:
    • <JBOSS_HOME>/server/default/deploy/archiva.war/WEB-INF/lib/commons-logging-1.0.4.jar (causes the Spring ContextClassLoader to throw an ExceptionInInstantiation)
    • <JBOSS_HOME>/server/default/deploy/archiva.war/WEB-INF/lib/log4j-1.2.8.jar (causes a logger ClassCastException)
    • <JBOSS_HOME>/server/default/deploy/archiva.war/WEB-INF/stax-api-1.0.1.jar (causes a ClassCastException. This jar conflicts with JBossWS)
    • <JBOSS_HOME>/server/default/deploy/archiva.war/WEB-INF/classes/log4j.xml (Removing log4j.xml will redirect all logging output to the container)
  1. To tell Archiva about the datasources you created in step 3 you need to create an application server specific deployment descriptor. Simply create a file <JBOSS_HOME>/server/default/deploy/archiva.war/WEB-INF/jboss-web.xml with the following content:
    No Format
    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-web>
     <resource-ref>
       <res-ref-name>jdbc/users</res-ref-name>
       <jndi-name>java:/jdbc/archiva_users</jndi-name>
     </resource-ref>
    <resource-ref>
       <res-ref-name>jdbc/archiva</res-ref-name>
       <jndi-name>java:/jdbc/archiva</jndi-name>
     </resource-ref>
     <resource-ref>
       <res-ref-name>mail/Session</res-ref-name>
       <jndi-name>java:/Mail</jndi-name>
     </resource-ref>
    </jboss-web>
    
  2. <JBOSS_HOME>/server/default/deploy/archiva.war/WEB-INF/classes/application.properties add the following line:
    No Format
    appserver.base=
    
    This will make it unnecessary to set the system property appserver.base.
  3. Make sure ~/.m2 (the subdirectory .m2 in the home directory of the user that is running JBoss) is writable.
  4. Restart the application server (or touch <JBOSS_HOME>/server/default/deploy/archiva.war/WEB-INF/web.xml to redeploy.)
  5. Goto http://your.application.server:8080/archiva/.

Archiva 1.2.2 On JBoss-AS 5.1 (and Java 6)

  1. Download the 1.2.2 war file
  2. Expand it in the JBoss deploy directory. There's no need to rename it
  3. Create a jboss-web.xml file in the WEB-INF directory with the following content:
    No Format
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE jboss-web PUBLIC
        "-//JBoss//DTD Web Application 5.0//EN"
        "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
    <jboss-web>
    
        <class-loading java2ClassLoadingCompliance='false'>
            <loader-repository>
                org.apache.archiva:loader=archiva
                <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
            </loader-repository>
        </class-loading>
    
        <context-root>archiva</context-root>
    
        <resource-ref>
            <res-ref-name>jdbc/users</res-ref-name>
            <jndi-name>java:/users</jndi-name>
        </resource-ref>
        <resource-ref>
            <res-ref-name>jdbc/archiva</res-ref-name>
            <jndi-name>java:/archiva</jndi-name>
        </resource-ref>
        <resource-ref>
            <res-ref-name>mail/Session</res-ref-name>
            <jndi-name>java:/Mail</jndi-name>
        </resource-ref>
    </jboss-web>
    
    Note that we use an external postgres database as described above, hence the resource-refs. Also, the JNDI name of the jdbc/users datasource resource-ref is more generic than the one described for JBoss 4.2 as we share this instance with Continuum.
  4. Remove the following jars from the WEB-INF/lib directory:

    geronimo-spec-jta-1.0.1B-rc2.jar

    provided by all JEE 1.2+ containers

    jsr-250-api-1.0.jar

    provided by all JEE 5+ containers

    jstl-1.1.2.jar

    provided by all JEE 1.4+ containers

    spring-*.jar

    see below

    stax-1.2.0.jar

    provided by all JEE 5+ containers

    stax-api-1.0.1.jar

    provided by all JEE 5+ containers

  5. Download the Spring Framework 3.0 distribution (currently RC1, and not yet available in the central repo). The Spring upgrade is necessary because the annotation scanner used in Spring 2.5.x is broken by JBoss 5.x's new VFS file system. See https://jira.springsource.org/browse/SPR-6146.
  6. Install the following Spring 3.0 jars:
    • org.springframework.asm-3.0.0.RC1.jar
    • org.springframework.beans-3.0.0.RC1.jar
    • org.springframework.context-3.0.0.RC1.jar
    • org.springframework.context.support-3.0.0.RC1.jar
    • org.springframework.core-3.0.0.RC1.jar
    • org.springframework.expression-3.0.0.RC1.jar
    • org.springframework.web-3.0.0.RC1.jar
  7. Replace xwork-2.0.5.jar with xwork-2.0.7.jar to rectify MRM-1206
  8. I also modified the WEB-INF/classes/log4j.xml, changing "${appserver.base}/logs" to "${jboss.server.log.dir}". This puts all the archiva logs in the jboss server logs directory.
    slf4j has a bit of a whinge when starting up, but logging seems to work OK.