Archiva on JBoss

Archiva on JBoss 4.0.5

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

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/.

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

3 Comments

  1. Archiva 1.2-m1 still seems to be working with this instruction, so shouldn't we just remove the out of date warning?

    The only thing that's missing in this documentation is the additional parameter that's needed nowadays
    -Dappserver.home=d:/data/archiva/

  2. For the Archiva 1.1.3 (and probably a lot of other versions) on Oracle you need to reed this Jira issue: http://jira.codehaus.org/browse/MRM-657

    It tells you to add the attached package-oracle.orm file in the archiva-model-x.x.x.jar next to the package.jdo

    You then need to set a property:
    -Djavax.jdo.option.Mapping=oracle

    for instance by adding this line to your start up script

  3. Hi, i am trying to install archiva 1.3.3 on JBoss 6.0.

    By try and error i found out, you should also delete the following jars:
    slfj-api*.jar
    quartz*.jar

    But then one error remains: Some problem with redback-authentication-ldap-1.2.5.jar

    Can anyone help me?

    Here is the stack trace:

    20:28:29,187 ERROR org.jboss.kernel.plugins.dependency.AbstractKernelController Error installing to PostClassLoader: name=vfs:///C:/progra
    ms/jboss-6.0.0.Final/server/default/deploy/apache-archiva-1.3.3.war state=ClassLoader mode=Manual requiredState=PostClassLoader: org.jboss.d
    eployers.spi.DeploymentException: Deployment error processing fragment for JAR: redback-authentication-ldap-1.2.5.jar
    at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) 2.2.0.GA
    at org.jboss.web.deployers.MergedJBossWebMetaDataDeployer.deploy(MergedJBossWebMetaDataDeployer.java:394) 6.0.0.Final
    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) 2.2.0.GA
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) 2.2.0.GA
    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) 2.2.0.GA
    at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) 2.2.0.GA
    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) 2.2.0.GA
    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) 2.2.0.GA
    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) 2.2.0.GA
    at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) 2.2.0.GA
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) 2.2.0.GA
    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) 2.2.0.GA
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) 2.2.0.GA
    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) 2.2.0.GA
    at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) 2.2.0.GA
    at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) 2.2.0.GA
    at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) 2.2.0.GA
    at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) 6.0.0.Final
    at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) 0.2.2
    at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.deploy(HDScanner.java:240) 0.2.2
    at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.complete(HDScanner.java:192) 0.2.2
    at org.jboss.profileservice.management.TwoPCActionWrapper.doComplete(TwoPCActionWrapper.java:57) 0.2.2
    at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.complete(AbstractTwoPhaseModificationAction.java:74) 0.2.2
    at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.prepare(AbstractTwoPhaseModificationAction.java:95) 0.2.2
    at org.jboss.profileservice.management.ModificationSession.prepare(ModificationSession.java:87) 0.2.2
    at org.jboss.profileservice.management.AbstractActionController.internalPerfom(AbstractActionController.java:234) 0.2.2
    at org.jboss.profileservice.management.AbstractActionController.performWrite(AbstractActionController.java:213) 0.2.2
    at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:150) 0.2.2
    at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:135) 0.2.2
    at org.jboss.profileservice.deployment.hotdeploy.HDScanner.scan(HDScanner.java:146) 0.2.2
    at org.jboss.profileservice.deployment.hotdeploy.HDScanner.run(HDScanner.java:90) 0.2.2
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) 1.6.0_23
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) 1.6.0_23
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) 1.6.0_23
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) 1.6.0_23
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180) 1.6.0_23
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204) 1.6.0_23
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 1.6.0_23
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 1.6.0_23
    at java.lang.Thread.run(Thread.java:662) 1.6.0_23
    Caused by: java.lang.IllegalStateException: Unresolved conflict on resource environment reference named: userMapper#ldap
    at org.jboss.metadata.javaee.spec.ResourceEnvironmentReferencesMetaData.augment(ResourceEnvironmentReferencesMetaData.java:78) 2.0.0.Alpha24
    at org.jboss.metadata.javaee.spec.RemoteEnvironmentRefsGroupMetaData.augment(RemoteEnvironmentRefsGroupMetaData.java:580) 2.0.0.Alpha24
    at org.jboss.metadata.javaee.spec.EnvironmentRefsGroupMetaData.augment(EnvironmentRefsGroupMetaData.java:191) 2.0.0.Alpha24
    at org.jboss.metadata.web.spec.WebCommonMetaData.augment(WebCommonMetaData.java:941) 2.0.0.CR1
    at org.jboss.web.deployers.MergedJBossWebMetaDataDeployer.deploy(MergedJBossWebMetaDataDeployer.java:390) 6.0.0.Final
    ... 38 more

    20:28:29,331 WARN org.jboss.profileservice.deployment.hotdeploy.HDScanner Scan failed: org.jboss.deployers.client.spi.IncompleteDeploymen
    tException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

        • DEPLOYMENTS IN ERROR: Name -> Error

    vfs:///C:/programs/jboss-6.0.0.Final/server/default/deploy/apache-archiva-1.3.3.war -> org.jboss.deployers.spi.DeploymentException: Deployme
    nt error processing fragment for JAR: redback-authentication-ldap-1.2.5.jar

    DEPLOYMENTS IN ERROR:
    Deployment "vfs:///C:/programs/jboss-6.0.0.Final/server/default/deploy/apache-archiva-1.3.3.war" is in error due to the following reason(s
    ): java.lang.IllegalStateException: Unresolved conflict on resource environment reference named: userMapper#ldap

    at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1370) 2.2.0.GA
    at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1316) 2.2.0.GA
    at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:968) 2.2.0.GA
    at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.checkComplete(MainDeployerPlugin.java:82) 6.0.0.Final
    at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.checkComplete(ProfileControllerContext.java:138) 0.2.2
    at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.deploy(HDScanner.java:246) 0.2.2
    at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.complete(HDScanner.java:192) 0.2.2
    at org.jboss.profileservice.management.TwoPCActionWrapper.doComplete(TwoPCActionWrapper.java:57) 0.2.2
    at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.complete(AbstractTwoPhaseModificationAction.java:74) 0.2.2
    at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.prepare(AbstractTwoPhaseModificationAction.java:95) 0.2.2
    at org.jboss.profileservice.management.ModificationSession.prepare(ModificationSession.java:87) 0.2.2
    at org.jboss.profileservice.management.AbstractActionController.internalPerfom(AbstractActionController.java:234) 0.2.2
    at org.jboss.profileservice.management.AbstractActionController.performWrite(AbstractActionController.java:213) 0.2.2
    at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:150) 0.2.2
    at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:135) 0.2.2
    at org.jboss.profileservice.deployment.hotdeploy.HDScanner.scan(HDScanner.java:146) 0.2.2
    at org.jboss.profileservice.deployment.hotdeploy.HDScanner.run(HDScanner.java:90) 0.2.2
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) 1.6.0_23
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) 1.6.0_23
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) 1.6.0_23
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) 1.6.0_23
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180) 1.6.0_23
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204) 1.6.0_23
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 1.6.0_23
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 1.6.0_23
    at java.lang.Thread.run(Thread.java:662) 1.6.0_23