Installing Apache Archiva on JBoss 4.2.3.GA
Apache Archiva is an extensible repository management software that helps taking care of your own personal or enterprise-wide build artifact repository. It is the perfect companion for build tools such as Maven, Continuum, and ANT.
Archiva offers several capabilities, amongst which remote repository proxying, security access management, build artifact storage, delivery, browsing, indexing and usage reporting, extensible scanning functionality… and many more!
This guide will show you, how to run Apache Archiva on JBoss AS 4.2.3.GA, with an external datasource using Apache Derby as the database.
Requirements
- Download Apache Archiva. This guide will be based on version 1.3.
- Download Apache Derby. Version 10.5.3.0 will be used here.
- Download JBoss Application Server 4.2.3.GA.
- Download Spring Framework 2.5.6.SEC01.
Datasource configuration
Archiva uses an external database for two purposes:
- Storing artifact information
- As a default user store for security
archiva-ds.xml file:
<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:/usr/local/java/archiva/database;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>
<local-tx-datasource>
<jndi-name>archiva</jndi-name>
<connection-url>jdbc:derby:/usr/local/java/archiva/database;create=true</connection-url>
<driver-class>org.apache.derby.jdbc.EmbeddedDriver</driver-class>
<user-name>sa</user-name>
<password></password>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>5</idle-timeout-minutes>
<track-statements/>
</local-tx-datasource>
</datasources>
Note: Archiva uses JNDI data sources to locate the databases to use:
- jdbc/archiva – the repository database
- jdbc/users – the user store
Creating the deployment descriptor
To tell Archiva about the datasources you created in step above you need to create an application server specific deployment descriptor. Simply create the jboss-web.xml file with the following content:
<!DOCTYPE jboss-web PUBLIC “-//JBoss//DTD Web Application 2.4//EN” “http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd”>
<jboss-web>
<class-loading java2ClassLoadingCompliance=”false”>
<loader-repository>
org.apache.maven.archiva:loader=archiva.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
<resource-ref>
<res-ref-name>jdbc/archiva</res-ref-name>
<jndi-name>java:/archiva</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>jdbc/users</res-ref-name>
<jndi-name>java:/users</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<jndi-name>java:/Mail</jndi-name>
</resource-ref>
</jboss-web>
Preparing the JBoss Server
- Add \db-derby-10.5.3.0-bin.zip\lib\derby.jar file to $JBOSS_HOME/server/<instance_name>/lib folder.
- Add archiva-ds.xml file to $JBOSS_HOME/server/<instance_name>/deploy folder.
- Add this two parameters to the JBoss service inicialization:
-Dappserver.home=”$JBOSS_HOME” -Dappserver.base=”$JBOSS_HOME”
Note: In the step above, replace the $JBOSS_HOME, with the full path of your operational system, where you installed the JBossAS.
Preparing the Archiva application
- Rename the war file to ‘archiva.war’, removing the version suffix.
- Remove the specific log4j.xml configuration file existing under \archiva.war\WEB-INF\classes\log4j.xml. This way the container logging configuration will be used.
- Remove \archiva.war\WEB-INF\lib\stax-api-1.0.1.jar. This jar causes a ClassCastException (conflicts with JBossWS).
- Add \spring-framework-2.5.6.SEC01.zip\dist\modules\spring-orm.jar to \archiva.war\WEB-INF\lib\ folder (1).
- Add the jboss-web.xml file to \archiva.war\WEB-INF\ folder
If you follow these steps, just deploy the application, copying the archiva.war to $JBOSS_HOME/server/<instance_name>/deploy folder and that’s it!
