Release Announcement: e-Mail Server Maven Plugin

The e-Mail Server Maven Plugin is a Maven plugin that launches an embedded mail server to support the automation of integration tests for components that require an SMTP, IMAP and/or POP3 server. The plugin has been available from the Maven Central for some time but I’ve just been too lazy to publicise it.

Continue reading

Posted in Testing | Tagged , , , , , , , , , , , , , | Leave a comment

Getting Apache Struts 2 to work on WebSphere 6.1

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.

 

Posted in Programming | Tagged , , | Leave a comment

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

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.

<?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>
view raw ra.xml This Gist brought to you by GitHub.

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

Rather than have to customize 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.

<?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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.jackrabbit</groupId>
    <artifactId>jackrabbit-jca-webpshere</artifactId>
    <version>2.2.9</version>
    <packaging>rar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>jackrabbit-jca</artifactId>
            <version>2.2.9</version>
        </dependency>
    </dependencies>
</project>
view raw pom.xml This Gist brought to you by GitHub.
Posted in Programming | Tagged , , , , | Leave a comment

Inject application context dependencies in Quartz job beans

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 and with 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;
  }
}
Posted in Programming | Tagged , , | 2 Comments

Release Announcement: Selenium JUnit 4 Runner 1.0

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.
Continue reading

Posted in Testing | Tagged , , | Leave a comment

Adding Google Analytics to a Maven generated site

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.

<?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>
Posted in Tooling | Tagged | Leave a comment

Installing Maven 3 on Ubuntu 11.04 LTS Server

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

Download the Maven 3.0.4 binary distribution from your local mirror:

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

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

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

Create symbolic link in /usr/bin:

$ sudo ln -s /usr/local/apache-maven-3.0.4/bin/mvn /usr/bin/mvn
Posted in Tooling | Tagged , , | 4 Comments