Note to self “you cannot use dependency injection in helper classes”

So after wasting a lot of time fighting against the current, and my desire to use the beautiful and clean dependency injection features in EJB3, I am now using the old messy lookin context lookup for resources in my helper classes.

I saw some post about passing resources, but having issues with threading. Just a note to myself to not try this again.

A service to test your application with various HTTP codes

This is a service to get HTTP codes for testing how your. stuff handles various HTTP codes.

The service is real simple to use; add a call like:

to see how your app handles a 404

There is a good list of codes here too

Install Firefox Java Plugin on Linux


This is silly but not super obvious and not easy to find on the interweb thingie searches come up with Oracle’s solution about linking the libjavaplugin_oji lib in the Mozilla plugins dir:

<Java installation directory>/plugin/i386/ns7/

which does not work for me. The way to get this going is to create a link to the libnpjp2 library in the Mozilla plugin directory as follows:

ln -s /<Java installation directory>/jre/lib/i386/ /usr/lib/mozilla/plugins/

Ubuntu Linux unable to mount non-journaled hfsplus drive for write

I have a drive from a Macbook that I made into a USB drive to share files between Linux and Macs. To do this I of course disabled journaling on the drive before removing it from the Macbook, and all was well. Both Linux (a Debian desktop machine) and various Mac machines could both read and write to the drive. However, I got a new notebook, which I installed Ubuntu on, and found it could only mount this non-journaled hfsplus USB drive as read only, though “mount” shows it mounted rw, for read and write. I tried many things and read many blogs and forum posts and decided to try the tools that come with in the “hfsprogs” package, and specifically “fsck.hfsplus” as someone speculated that the drive might have been become corrupt during an unmount.  The command I ran was:

sudo fsck.hfsplus /dev/sdb2

This check did indeed find some errors and report it had correct them and afterwards I could once again write to the drive.

I hope this helps the next person searching for this issue. I tried to get all the terms I was searching for, unsuccessfully, into title of this post to help folks locate it. Searching for this issue seems to turn up 99.9% responses about “You have to turn off journaling before mounting with Linux” which I knew already and was not part of the problem at all.

Use the Android SDK Emulator with Eclipse behind a Proxy

In the office we have a pretty stern internet proxy and I needed to test something from the Android Emulator using the network today, and therefore the Proxy. This seemed like a simple thing to do, and there are instructions for adding proxy information when launching the Emulator  on the Android Developer site ( So I went into preferences for Eclipse, chose the Android preferences and sure enough, on the lunch tab there is a field for parameters when launching the Emulator. I added the proxy string there as per the document (-http-proxy user:pass@server:port) e.g.


but it did not seem to take. A little searching in some forums solved this however. I am adding it here with a title that matches what I was searching for via Google so that the next person can find it without reading a lot of forum threads.

The trick is that you need to add this info on for the project you are going to be running it from, and there is a convenient place to do so in Eclipse. With the project selected,  choose “Run” from the menu bar at the top, then “Run Configurations” This will show all the run configurations, and have the current project selected. You can also choose the Run/Configurations items from any project and select the correct one once inside. Once a configuration is chosen, choose the “Target” tab from the tabs on the right side of the Run Configurations dialog and look for the Text field labeled “Additional Emulator Command Line Options”. I had to resize the Dialog window to get this box to appear as there are no scrollpanes used there (I am using Linux version 3.5.2. of Eclipse). Below are a couple screen shots of these dialogs.

Access and use Java Properties in Spring Context file

This seems like such a simple thing to do, and yet finding a nice simple example online was a real bear (A BEAR!!! actually). So here is my example so the next person will have an easier time of it.

Add properties to your properties file:


Load the properties file inside the context file:

<property name=”locations”>

Access properties from the properties file when setting properties of a bean:

<bean id=”searchButtonBean” init-method=”init” class=”javax.swing.JButton”>
<property name=”text”>
<property name=”buttonIcon” value=”${}”/>

Apache ANT If Else Condition without ANT-Contrib

Sometimes I must make an ANT Build file that will need to work on many different machines, where I cannot be sure of the version or configuration of ANT nor the environment it is running in. This can cause some discomfort when it comes to complex builds involving conditions. The ANT-Contrib library has a convenient If/Else condition but this library is not always installed with ANT or even when it is, the build environment may not be configured to use it. So in either case, I use the following method which, though a little wordy, gets the job done without relying on anything beyond a standard ANT install. The method uses three ANT targets to do the work, one for the <if>, one for the <then> and one for the <else>. As you can see it creates a bit of extra code, but I believe the portability is worth it.

Below the explanation, the example referred to in the post will be made available. Now lets get started.

First Create a target that should do some bit of work based on a condition. Make the target depend on two other targets (here these are “setup” and “fail”), and only allow it to execute if a boolean variable has the right value, using the “if” attribute of the “target” element.

<target name=”go” depends=”setup, fail” if=”allIsWellBool”>

Next, have one of the dependencies create a boolean property based on the condition. The process is a little convoluted, in that you need to use a <condition> construct that has an <equals> test against text to create a boolean property. For instance, in the example for this post, this dependency target, “setup”, asks for some user input, then checks to see if an empty string was entered. A new boolean property is added based on the test.

<target name=”setup”>
<input message=”Please enter something:” addproperty=”somethingProp”/>

<condition property=”allIsWellBool”>
<equals arg1=”${somethingProp}” arg2=”” trim=”true”/>

After this target either there is a new boolean property called “allIsWellBool” or there is not. Subsequent test for this property will pass if the property is there, and true, or fail if it is not.

Finally, create a target to execute if the test fails, the else condition basically. This is done by only allowing it to execute if a boolean variable has the right value again, but this time using the “unless” attribute of the “target” element. In the case of the example for this post, this target will execute unless the “allIsWellBool” exists and is true.

<target name=”fail” depends=”setup” unless=”allIsWellBool”>
<fail message=”You must enter something”/>

See also that we are adding the dependency for the “setup” target here as well. This is because this target depends on a property that is set in the “setup” target, and “setup” should therefore happen first.

The full source of the example mentioned in this post is below.

<?xml version="1.0" encoding="UTF-8"?>
    Simple example of how to do an If/Else condition in
    your build file without using the ANT-Contrib libs

    This source code is provided free of charge and placed in the
    public domain. It is not supported by anyone.

    Use this at your own risk.
<project name="Test If Else Condition without ANT-Contrib" default="go">

    <!-- ======================= -->
    <target name="go" depends="setup, fail" if="allIsWellBool">

        <echo message="Great, passed the test, lets do something!"/>
        <!-- SHOULD DO SOMETHING -->


    <!-- =================================================== -->
    <target name="setup">

        <input message="Please enter something: " addproperty="somethingProp"/>

        <condition property="allIsWellBool">
                <equals arg1="${somethingProp}" arg2="" trim="true"/>

    <!-- ============================================ -->
         IS FALSE
    <target name="fail" depends="setup" unless="allIsWellBool">
        <fail message="You must enter something"/>