You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Archiva on JBoss

Archiva on JBoss 4.0.5

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

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

<?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

<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

<?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:
    <?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:
    <?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:
    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/.
  • No labels