Efficient Singletons in legacy code
The app I’m maintaining is not Spring-enabled so I am faced with the possibility of writing code for singleton objects. To my mild surprise, I discovered that Java 5 has made singleton creation considerably less bug-prone. There’s also better practices for double-checked locking, if your code (attempts to) swing that way.
Separating Unit tests from Acceptance tests in maven
Have been playing with Maven a lot in the last week and a half. One thing I liked about Ant was the control over whether various classes of test would run in which target.
Found a post by Abhi which demonstrates that a judicious use of profiles will accomplish this.
Maven: Not as terrible as it seems
I once read a quote about Maven, that
it makes the simple things effortless, and the difficult things impossible
After working with it full-time for, wow, has it been a year already? I still believe that statement is true for beginners. Eventually, though, you learn how to work with Maven rather than against it, but still get it to do what you want.
Document base /path/to/exploded/war/ does not exist or is not a readable directory
I discovered the easy technique where one can point Tomcat at a directory instead of copying stuff into the /webapps dir.
So, I created $CATALINA_HOME/conf/Catalina/localhost/ma.xml like so:
<Context path="/ma" docBase="/workspace/ma/target/ma" reloadable="true" />
After a few false starts (turns out that Tomcat on Windows doesn’t accept cygwin-style paths even when started from sygwin), I thought I had it sorted.
<Context path="/ma" docBase="d:\workspace\ma\target\ma" reloadable="true" />
but Tomcat was having none of it.
16/06/2011 5:04:23 PM org.apache.catalina.core.StandardContext resourcesStart SEVERE: Error starting static Resources java.lang.IllegalArgumentException: Document base D:\workspace\ma\target\ma does not exist or is not a readable directory
Turns out I was being stupid and forgot the trailing slash in the docBase.
Derp.
Back online
My PC died on the weekend (CPU fried after heat sink detached) so I used the opportunity to buy a Macbook Pro.
It’s exceptionally nice with a great keyboard, but the trackpad scrolls in entirely the wrong direction compared to smart phones.
Turns out Apple will fix this in OSX Lion but until then, you can download a handy app that will unwrongify your scrolling.