Stuff I don't want to forget. Again!

View libraries bundled in Spring Boot distribution

30 October 2017

This the command that I use when I want to see what dependencies got bundled into my Spring Boot distribution JAR files:

 jar -tvf filename.jar | grep jar$ | awk '{print $8}' | sed 's/BOOT-INF\/lib\///' | sort

Setting active profiles when launching Spring Boot application via gradle

21 February 2016

I wanted to use a profile specific application.properties file for my Spring Boot application. But Gradle was not picking it up when I ran my launched with the following command:

gradle bootRun -Dspring.profiles.active=dev

The solution turned out be be simply adding the snippet below to my build.gradle file. This snippet is telling Gradle to pull in the system properties.

bootRun {
    systemProperties = System.properties
}

CRX Maven Plugin 1.2.1 Released

15 February 2016

This release of the CRX Maven Plugin addresses issues some people were having with PEM files exported from Google Chrome. The solution involved updating the Bouncy Castle dependency to version 1.54.

LDAP Maven Plugin 1.3.0 Released

14 February 2016

The LDAP Maven Plugin was relying on the jcabi-aether library to resolve dependencies. When I first wrote the LDAP Maven Plugin I couldn’t find much information on how to resolve dependencies and jcabi-aether proved to be invaluable. Aether is dependency resolution framework used under the hood by Maven 3 and higher.

Aether was originally managed by Sonatype but it was moved to stewardship of the Eclipse foundation. Since Maven 3.1 the Eclipse version has been used.

Since I wanted to the maintain support for Maven 3.0.5 I decided to revert to the Maven 2 dependency resolution API.

In addition, I downgraded the version of ApacheDS used by the plugin to 1.5.5. I was having trouble resolving one of the transitive dependencies for 2.0.0-M15 during integration testing and I didn’t have any luck using the latest version (2.0.0-M17) or later. So I decided to downgrade for now and revisit the issue when ApacheDS 2.0.0 is released and documentation on embedding it becomes available.

Release Announcement – LDAP Maven Plugin 1.2.0

26 September 2014

The LDAP Maven Plugin is a Maven plugin that can:

  • Import/export data to/from a LDAP directory server. Both the LDIF and DSML formats are supported.

  • Launch and shutdown a LDAP directory server in the Maven build life-cycle. The plugin supports the following LDAP directory servers:

Importing or exporting data

The plugin provides the following goals to import or export content from a LDAP directory server:

  • load is used to load content from a file into a LDAP directory server.

  • dump is used to dump content to a file from a LDAP directory sever.

The following file formats are supported:

  • LDIF – LDAP Directory Interchange Format

  • DSML – Directory Services Markup Language

LDAP Data Interchange Format (LDIF)

Import

The following POM fragment demonstrates how to load content into a LDAP directory server from a LDIF formatted file using the load goal of the LDAP Maven Plugin.

<plugin>
    <groupId>com.btmatthews.maven.plugins</groupId>
    <artifactId>ldap-maven-plugin</artifactId>
    <version>1.2.0</version>
    <executions>
        <execution>
            <id>load</id>
            <goals>
                <goal>load</goal>
            </goals>
            <configuration>
                <host>localhost</host>
                <port>10389</port>
                <authDn>uid=admin,ou=system</authDn>
                <passwd>secret</passwd>
                <sources>
                    <ldif>load.ldif</ldif>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

Export

The following POM fragment demonstrates how to export content from a LDAP directory server to a LDIF formatted file using the dump goal of the LDAP Maven Plugin.

<plugin>
    <groupId>com.btmatthews.maven.plugins</groupId>
    <artifactId>ldap-maven-plugin</artifactId>
    <version>1.2.0</version>
    <executions>
        <execution>
            <id>dump</id>
            <goals>
                <goal>dump</goal>
            </goals>
            <configuration>
                <host>localhost</host>
                <port>10389</port>
                <authDn>uid=admin,ou=system</authDn>
                <passwd>secret</passwd>
                <searchBase>dc=btmatthews,dc=com</searchBase>
                <filename>dump.ldif</filename>
                <format>ldif</format>
            </configuration>
        </execution>
    </executions>
</plugin>

Directory Service Markup Language (DSML)

Import

The following POM fragment demonstrates how to load content into a LDAP directory server from a DSML formatted file using the load goal of the LDAP Maven Plugin.

<plugin>
    <groupId>com.btmatthews.maven.plugins</groupId>
    <artifactId>ldap-maven-plugin</artifactId>
    <version>1.2.0</version>
    <executions>
        <execution>
            <id>load</id>
            <goals>
                <goal>load</goal>
            </goals>
            <configuration>
                <host>localhost</host>
                <port>10389</port>
                <authDn>uid=admin,ou=system</authDn>
                <passwd>secret</passwd>
                <sources>
                    <dsml>${basedir}/load.dsml</dsml>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

Export

The following POM fragment demonstrates how to export content from a LDAP directory server to a DSML formatted file using the dump goal of the LDAP Maven Plugin.

<plugin>
    <groupId>com.btmatthews.maven.plugins</groupId>
    <artifactId>ldap-maven-plugin</artifactId>
    <version>1.2.0</version>
    <executions>
        <execution>
            <id>dump</id>
            <goals>
                <goal>dump</goal>
            </goals>
            <configuration>
                <host>localhost</host>
                <port>10389</port>
                <authDn>uid=admin,ou=system</authDn>
                <passwd>secret</passwd>
                <searchBase>dc=btmatthews,dc=com</searchBase>
                <filename>dump.dsml</filename>
                <format>dsml</format>
            </configuration>
        </execution>
    </executions>
</plugin>

Running an LDAP Server in the build life-cycle

pom.xml

The following POM fragment uses the run goal to launch an embedded LDAP directory server prior to the execution of the integration tests and then uses the stop goal to shutdown the embedded LDAP directory server upon completion of the integration tests.

<?xml version="1.0" encoding="UTF-8"?>
<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.btmatthews.maven.plugins</groupId>
          <artifactId>ldap-maven-plugin</artifactId>
          <version>1.2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.btmatthews.maven.plugins</groupId>
        <artifactId>ldap-maven-plugin</artifactId>
        <version>1.2.0</version>
        <configuration>
          <monitorPort>11389</monitorPort>
          <monitorKey>ldap</monitorKey>
          <daemon>true</daemon>
        </configuration>
        <executions>
          <execution>
            <id>start-ldap</id>
            <goals>
              <goal>run</goal>
            </goals>
            <phase>pre-integration-test</phase>
          </execution>
          <execution>
            <id>stop-ldap</id>
            <goals>
              <goal>stop</goal>
            </goals>
            <phase>post-integration-test</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Connecting in Java

The following LDAP client libraries can be used to connect to the embedded LDAP server:

The LDAPUnit library provides an assortment of assertion and verification methods for use in unit and integration test cases.

Maven Central Coordinates

The LDAP Maven Plugin has been published in Maven Central at the following coordinates:

<plugin>
  <groupId>com.btmatthews.maven.plugins</groupId>
  <artifactId>ldap-maven-plugin</artifactId>
  <version>1.2.0</version>
</plugin>

License & Source Code

The LDAP Maven Plugin is made available under the Apache License and the source code is hosted on GitHub at https://github.com/bmatthews68/ldap-maven-plugin.

Installing Photomatix pre-sets on Mac OS X

31 August 2014

I downloaded a load of Photomatix pre-sets from http://alikgriffin.com/. They came as an archive of .xmp files without any instructions on how to install them.

Fortunately I had already created and saved a pre-set so I just had to locate that on the file system. I found it in my ~/Application Support/Photmatix/Presets folder. Then I just dragged the contents of the archive into that folder and now I have 25 shiny new pre-sets to play with.

Release Announcement – In-Memory Database Maven Plugin – 1.4.0

08 January 2014

I am pleased to announce the availability of the In-Memory Database Maven Plugin version 1.4.0.

This release adds two new configuration settings:

  • <skip/> can be used to skip executing the plugin goals.

  • <attributes/> can be used to append additional options to the JDBC url connection string.

Using <skip/>

The <skip/> configuration option can be specified in the <configuration/> section for the plugin or an individual plugin execution. Typically this would be used to disable unit or integration tests:

<skip>${maven.test.skip}</skip>

The same can also be achieved passing the inmemdb.skip system property on the Maven command line:

$ mvn -Dinmemdb.skip clean install

Using <attributes/>

Additional attributes can be appended to the JDBC URL connection string using the <attributes/> element nested inside the <configuration/> section for the plugin or an individual plugin execution. For example:

<attributes>
    <territory>ga_IE</territory>
</attributes>

Maven Central Coordinates

The In-Memory Database Maven Plugin has been published in Maven Central at the following coordinates:

<plugin>
    <groupId>com.btmatthews.maven.plugins.inmemdb</groupId>
    <artifactId>inmemdb-maven-plugin</artifactId>
    <version>1.4.0</version>
</plugin>

Credits

This project contains contributions from:

License

The In-Memory Database Maven Plugin is made available under the Apache License and the source code is hosted on GitHub at https://github.com/bmatthews68/inmemdb-maven-plugin.

Release Announcement – In-Memory Database Maven Plugin – 1.4.0

08 January 2014

I am pleased to announce the availability of the In-Memory Database Maven Plugin version 1.4.0.

This release adds two new configuration settings:

  • <skip/> can be used to skip executing the plugin goals.

  • <attributes/> can be used to append additional options to the JDBC url connection string.

Using <skip/>

The <skip/> configuration option can be specified in the <configuration/> section for the plugin or an individual plugin execution. Typically this would be used to disable unit or integration tests:

<skip>${maven.test.skip}</skip>

The same can also be achieved passing the inmemdb.skip system property on the Maven command line:

$ mvn -Dinmemdb.skip clean install

Using <attributes/>

Additional attributes can be appended to the JDBC URL connection string using the <attributes/> element nested inside the <configuration/> section for the plugin or an individual plugin execution. For example:

<attributes>
    <territory>ga_IE</territory>
</attributes>

Maven Central Coordinates

The In-Memory Database Maven Plugin has been published in Maven Central at the following coordinates:

<plugin>
    <groupId>com.btmatthews.maven.plugins.inmemdb</groupId>
    <artifactId>inmemdb-maven-plugin</artifactId>
    <version>1.4.0</version>
</plugin>

Credits

This project contains contributions from:

License

The In-Memory Database Maven Plugin is made available under the Apache License and the source code is hosted on GitHub at https://github.com/bmatthews68/inmemdb-maven-plugin.

Getting Apache Struts 2 to work on WebSphere 6.1

24 February 2012

On a recent project I had problems deploying a web application built on the Struts 2 MVC framework to a fresh WebSphere installation. I wasted a lot of time labouring under the incorrect assumption (for once) that the architectural changes I had introduced in the latest sprint were the cause of my troubles.

But it turned out to be an environmental issue. We were deploying Struts 2 as a servlet filter and out of the box WebSphere does not support HTTP requests that are served by a servlet filter. A custom property called com.ibm.ws.webcontainer.invokefilterscompatibilty must be set for the web container. I guess I should have just deployed straight to the UAT environment!

Here is the procedure for setting the com.ibm.ws.webcontainer.invokefilterscompatibility custom property:

  1. In the administrative console click Servers > Application Servers > server_name > Web Container Settings > Web Container.

  2. Under Additional Properties select Custom Properties.

  3. On the Custom Properties page, click New.

  4. On the settings page, enter com.ibm.ws.webcontainer.invokefilterscompatibility in the Name field and true in the Value field.

  5. Click Apply or OK.

  6. Click Save on the console task bar to save your configuration changes.

  7. Restart the server.

Deploying Jackrabbit 2.2.x on WebSphere 6.1 as a Shared J2EE Resource

22 December 2011

On my current assignment we are developing a multi-tennant web application and are giving the individual tennants the ability to customize the look and feel of the application. We are using Jackrabbit to host the style sheets, images and scripts that for each of the look and feels.

Initially I tried to deploy Jackrabbit as using the Shared J2EE Resource deployment model on WebSphere 6.1. Due to a leathal cocktail of stupidity and environmental constraints I couldn’t get it working earlier in the project and decided to settle for the Application Bundle deployment model.

Now we need to have more that one instance of the application running in the test environment and we’ve had to finally figure out how to get the Shared J2EE Resource deployment model up and running.

It turned out to be a lot easier than I exepcted. In order to get Jackrabbit working I just needed to customize the ra.xml deployment descriptor from jackrabbit-jca-2.2.x.rar by changing the <transaction-support/> element to from XATransaction to NoTransaction.

ra.xml
<?xml version="1.0" encoding="UTF-8"?>
<connector
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://java.sun.com/xml/ns/j2ee
        http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
    version="1.5" >
    <display-name> Apache Jackrabbit JCR Adapter</display-name>
    <vendor-name> The Apache Software Foundation</vendor-name>
    <eis-type> JCR Adapter</eis-type>
    <resourceadapter-version> 1.0</resourceadapter-version>
    <resourceadapter>
        <resourceadapter-class>org.apache.jackrabbit.jca.JCAResourceAdapter </resourceadapter-class>
        <outbound-resourceadapter>
            <connection-definition>
                <managedconnectionfactory-class>org.apache.jackrabbit.jca.JCAManagedConnectionFactory</managedconnectionfactory-class>
                <config-property>
                    <config-property-name>RepositoryURI</config-property-name>
                    <config-property-type>java.lang.String</config-property-type>
                </config-property>
                <config-property>
                    <config-property-name>HomeDir</config-property-name>
                    <config-property-type>java.lang.String</config-property-type>
                </config-property>
                <config-property>
                    <config-property-name>ConfigFile</config-property-name>
                    <config-property-type>java.lang.String</config-property-type>
                </config-property>
                <connectionfactory-interface>javax.jcr.Repository</connectionfactory-interface>
                <connectionfactory-impl-class>org.apache.jackrabbit.jca.JCARepositoryHandle</connectionfactory-impl-class>
                <connection-interface>javax.jcr.Session</connection-interface>
                <connection-impl-class>org.apache.jackrabbit.jca.JCASessionHandle</connection-impl-class>
            </connection-definition>
            <transaction-support>NoTransaction</transaction-support>
            <reauthentication-support>false</reauthentication-support>
        </outbound-resourceadapter>
    </resourceadapter>
</connector>

This change is necessary because Jackrabbit does not support local transactions and actually raises an exception when called by WebSphere.

Rather than have to customise this by hand I a put together the Maven POM below to build custom RAR for me. You must place the ra.xml deployment descriptor in src/main/rar/META-INF.

Inject application context dependencies in Quartz job beans

24 September 2011

The SpringBeanJobFactory allows you to inject properties from the scheduler context, job data map and trigger data entries into the job bean. But there is no way out of the box to inject beans from the application context.

So I came up with the factory bean below that extends the SpringBeanJobFactory to add auto-wiring support:

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.quartz.SpringBeanJobFactory;

public final class AutowiringSpringBeanJobFactory
    extends SpringBeanJobFactory
    implements ApplicationContextAware {

  private transient AutowireCapableBeanFactory beanFactory;

  public void setApplicationContext(
      final ApplicationContext context) {
    beanFactory = context.getAutowireCapableBeanFactory();
  }

  @Override
  protected Object createJobInstance(
        final TriggerFiredBundle bundle)
      throws Exception {
    final Object job = super.createJobInstance(bundle);
    beanFactory.autowireBean(job);
    return job;
  }
}

Adding Google Analytics to a Maven generated site

17 September 2011

You can add Google Analytics to a site generated with the Maven Site Plugin as by adding a <googleAnalyticsAccountId/> element containing your Web Property ID.

site.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<project
    xmlns="http://maven.apache.org/DECORATION/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://maven.apache.org/DECORATION/1.1.0
        http://maven.apache.org/xsd/decoration-1.1.0.xsd"
    name="...">

    <googleAnalyticsAccountId>...</googleAnalyticsAccountId>
    .
    .
    .
</project>

Release Announcement: Selenium JUnit 4 Runner 1.0

11 September 2011

I recently released Selenium JUnit 4 Runner. It is an extension for JUnit 4 providing a test runner to execute Selenium test cases. Both the Selenium 1.0 (Server) and 2.0 (Web Driver) APIs are supported.

Here is a very simple example:

@RunWith(SeleniumJUnit4ClassRunner.class)
    @WebDriverConfiguration
    public GoogleHomePageTest {

    @SeleniumWebDriver
    private WebDriver webDriver;

    @Test
    public void testGoogleSearch() {
        webDriver.navigate().to("http://www.google.com");
        assertEquals("Google", webDriver.getTitle());
    }
}

The Selenium JUnit 4 Class Runner launches the Selenium web driver or connects to the Selenium server before executing any methods annotated with @BeforeClass. It then autowires any members of the test class or method rules that have been annotated with @SeleniumBrowser or @SeleniumWebDriver.

Maven Coordinates Selenium JUnit 4 Runner is available from Maven Central at the following coordinates:

<dependency>
    <groupId>com.btmatthews.selenium.junit</groupId>
    <artifactId>selenium-junit4-runner</artifactId>
    <version>1.0.0</version>
    <type>test</type>
</dependency>

Installing Maven 3 on Ubuntu 11.04 LTS Server

04 August 2011

The instructions below are based on Installing Maven 3 on Ubuntu 10.04 LTS Server from Luke Bourke. I am installing Maven 3.0.3 on Ubuntu 11.04 LTS Server with Oracle Java 6.

Download the Maven 3.0.3 binary distribution from your local mirror:

$ wget http://ftp.heanet.ie/mirrors/www.apache.org/dist/maven/binaries/apache-maven-3.0.3-bin.tar.gz

Uncompress the binary distribution and copy it to the /usr/local directory:

$ tar -zxf apache-maven-3.0.3-bin.tar.gz
$ sudo cp -R apache-maven-3.0.3 /usr/local

Create symbolic link in /usr/bin:

$ sudo ln -s /usr/local/apache-maven-3.0.3/bin/mvn /usr/bin/mvn

i &gt;= 1 &amp;&amp; i &#8656; 26

02 July 2010

Almost 90 years after it happened, I’ve been forced to recognise partition for the first time in my life.

And the irony is that it is the Irish government that is forcing me to do it. I’ve had to add some validation logic to a drop down list for an e-government web application I’m working on. The drop down list only contains 26 counties!

Installing Sun Java 6 on Ubuntu 10.04 (Lucid Lynx)

01 July 2010

I came across this post that almost completely explains how to get Sun Java SE 6 installed on Ubuntu 10.04 (Lucid Lynx).

$ do apt-get install python-software-properties
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

The problem I had with the original post was that add-apt-repository was not available until I installed the python-software-properties package.

Getting JSP EL to work on Google App Engine

04 January 2010

I am developing an Spring 3.0 based web application that I intend to deploy to Google App Engine. But I’ve been banging my head against a brick wall for a day now trying to figure out why my ${xxx} expressions are not evaluating correctly.

The source of the problem seems to be a bug with Google App Engine. It would appear that even though I am using a Servlet 2.5 deployment descriptor that Google App Engine is behaving as if it was Servlet 2.3.

In Servlet 2.3 JSP expression language was not evaluated by default and it had to be explicitly enabled using the following below. However, since Servlet 2.4 the default behaviour is to evaluate the JSP expression language.

<%@ page isELIgnored="false" %>

So adding the above directive to my JSP page sorted my Google App Engine woes. But not before I’d developed some nasty bruising on my forehead.

How to install Java 6 JDK on Ubuntu

07 September 2009

It couldn’t be easier. Just execute the following commands in your favourite shell:

$ sudo apt-get install sun-java6-jdk sun-java6-plugin
$ update-java-alternatives -s java-6-sun

And add the following /usr/lib/jvm/java-6-sun to the top of the list in your /etc/jvm file.

Déjà Vu – Using the Maven Assembly Plugin correctly

04 June 2009

If you want to create an archive (.zip, .tar.gz, etc.) file as part of a Maven 2 build you need to use the Assembly Plug-in. Furthermore, if you want to install it into your local repository or deploy it to a remote repository you will need the assistance of the Builder Helper Plug-in.

But if you are building a multi-module project you need to do it properly or you can severely mess up your build. I’ve just spent the last 2 weeks going round in circles trying to figure out why we couldn’t build our project from the root project. In the end it turned out to be the fact that I was incorrectly using the assembly goal instead of the single goal. This was causing Maven to fork and try to build all the project dependencies again. To us it looked like our dependencies were not getting installed into the local repository and it was going out to get the last good snapshot build of the components from our remote repository which were 2 weeks out of date by this time.

Of course. Once I found the solution a little light bulb went off and I remembered I’d already seen this problem before. About two years ago in fact.

Here is a sample POM snippet that assumes an assembly descriptor with an id of bin and a format of .tar.gz:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-assembly-plugin</artifactId>
      <executions>
        <execution>
          <id>package</id>
          <goals>
            <goal>single</goal>
            </goals>
          <phase>package</phase>
        </execution>
      </executions>
      <configuration>
        <!-- Configure filters & descriptors -->
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <executions>
        <execution>
          <id>attach-artifacts</id>
          <phase>package</phase>
          <goals>
            <goal>attach-artifact</goal>
          </goals>
          <configuration>
            <artifacts>
              <artifact>
                <file>${project.build.directory}/${project.artifactId}-${project.version}-bin.tar.gz</file>
                <type>tar.gz</type>
                <classifier>bin</classifier>
              </artifact>
            </artifacts>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Building JBoss Service Archives (SARs) with Maven 2

29 May 2009

I discovered the following Maven 2 plugins capabable of building JBoss Service ARchives (SARs).

The JBoss Maven Plugin is the better of the two because it will bundle the project dependencies into the generated SAR along with the compiled classes and resources. Whereas the Maven SAR plugin only bundles the compiled classes and resources.

The following POM extract demonstrates the usage of the JBoss Maven Plugin:

<?xml version="1.0" encoding="UTF-8"?>
<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <packaging>jboss-sar</packaging>
  .
  .
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jboss-packaging-maven-plugin</artifactId>
        <version>2.0-beta-1</version>
        <extensions>true</extensions>
      </plugin>
      .
      .
    </plugins>
  </build>
  .
  .
</project>

Disabling system beep in VMware

26 May 2009

I’ve recently been plaged by an obnoxiously loud system beep from VMware Workstation. I hunted around the Internet and discovered that adding the following to the .vmx configuration file for the virtual machine will silence it forever.

mks.noBeep = "TRUE"

Deploying Archiva to JBoss 4.2

20 February 2009

After jumping through a few hoops I managed to get Archiva 1.1.3 successfully deployed to JBoss 4.2.3.

Set the appserver.base and appserver.home properties by adding the following lines to $JBOSS_HOME/bin/run.sh and restart JBoss.

JAVA_OPTS="-Dappserver.home=$JBOSS_HOME -Dappserver.base=$JBOSS_HOME $JAVA_OPTS"

Now create data source deployment descriptors for the archiva and users databases and copy them to $JBOSS_HOME/server/default/deploy. I am using MySQL 5.1 to as my database server.

archiva-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
    <jndi-name>jdbc/archiva</jndi-name>
    <connection-url>jdbc:mysql://localhost/archiva/connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>archiva</user-name>
    <password><!-- Password --></password>
  </local-tx-datasource>
</datasources>
users-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
    <jndi-name>jdbc/users</jndi-name>
    <connection-url>jdbc:mysql://localhost/users/connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>archiva</user-name>
    <password><!-- Password --></password>
  </local-tx-datasource>
</datasources>

Add WEB-INF/jboss-web.xml to the .war file.

WEB-INF/jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web
  PUBLIC "-//JBoss//DTD Web Application 2.4//EN"
  "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
<jboss-web>
  <context-root>archiva</context-root>
  <resource-ref>
    <description>Archiva Database</description>
    <res-ref-name>jdbc/archiva</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <jndi-name>java:/jdbc/archiva</jndi-name>
    <res-auth>Container</res-auth>
  </resource-ref>
  <resource-ref>
    <description>Users Database</description>
    <res-ref-name>jdbc/users</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <jndi-name>java:/jdbc/users</jndi-name>
    <res-auth>Container</res-auth>
  </resource-ref>
  <resource-ref>
    <description>Mail Session</description>
    <res-ref-name>mail/Session</res-ref-name>
    <res-type>javax.mail.Session</res-type>
    <jndi-name>java:/Mail</jndi-name>
    <res-auth>Container</res-auth>
  </resource-ref>
</jboss-web>

Remove the following from the WEB-INF/lib folder of apache-archiva-1.1.3.war because they will cause conflicts with:

  • commons-logging-api-1.1.jar

  • log4j-1.2.14.jar

Copy apache-archiva-1.1.3.war to $JBOSS_HOME/server/default/deploy.


Older posts are available in the archive.

Brian Matthews