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 to add auto-wiring support:

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.

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.

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

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 >= 1 && i <= 26

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)

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

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.

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

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 singlegoal. 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:

Building JBoss Service Archives (SARs) with Maven 2

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: