Category Archives: Java

Using system properties in with Spring

This is actually pretty easy to pull off. First you must use a property-placeholder like this: [xml] <context:property-placeholder location="classpath:myapp.properties" system-properties-mode="ENVIRONMENT"/> [/xml] The system-properties-mode supports several options including: FALLBACK – Indicates placeholders should be resolved against any local properties and then against system properties NEVER – Indicates placeholders should be resolved only against local properties and… Read More »

Using PowerMock to mock a call to super

Let’s say you are wanting to test UberEmployee below: [java] public class Employee { public int calculatePay() { return someComplexCalculations; } } public class UberEmployee { public static final long UBER_BONUS = 1000; @Override public int calculatePay() { return super.calculatePay() + 1000; } } [/java] Perhaps you can’t change Employee but you still want to… Read More »

Axis2, Maven, and java.net woes and why Maven sucks

I had some interesting problems trying to use the Axis2’s Maven plugin (1.5.1) for generating java code from a WSLD. Here’s what I did to get it working. First thing’s first I had to define the plugin in my POM: [xml] <plugin> <groupId>org.apache.axis2</groupId> <artifactId>axis2-wsdl2code-maven-plugin</artifactId> <version>1.5.1</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>wsdl2code</goal> </goals> </execution> </executions> <configuration> <packageName>com.ashlux.myproject</packageName>… Read More »

Issues with IntelliJ IDEA 9 M1 (Maia) in Linux and OSX (build #10372)

IntelliJ 9 (codenamed Maia) looks promising with lots and lots of great features. There seems to be an endless list of newly supported technologies, tweaks, and usability features. Maia has been superb in Mac OSX Snow Leopard. Unfortunately, my Ubuntu 9.04 desktop is an entirely different story. A big feature of Maia that I’m looking… Read More »

Five code commenting anti-patterns

In some projects (most?) comments multiply like tribbles creeping up everywhere. Sometimes the comments are especially useful but other times comments useless are destructive to maintainability. Contrary to some beliefs, bad and inaccurate comments are not mostly harmless. Bad comments take many forms. There are four forms that I think could be considered anti-patterns: 1.… Read More »

Hudson and the Sonar plugin fail: MavenInstallation NoSuchMethodError

We ran into an interesting and less than informative error when configuring Maven with our Hudson installation. Maven worked great, as expected, but the Sonar plugin stopped working and were causing builds to fail. The error message wasn’t terribly helpful: FATAL: hudson.tasks.Maven$MavenInstallation.forNode(Lhudson/model/Node;Lhudson/model/TaskListener;)Lhudson/tasks/Maven$MavenInstallation; java.lang.NoSuchMethodError: hudson.tasks.Maven$MavenInstallation.forNode(Lhudson/model/Node;Lhudson/model/TaskListener;)Lhudson/tasks/Maven$MavenInstallation; at hudson.plugins.sonar.SonarPublisher.getMavenInstallationForSonar(SonarPublisher.java:204) at hudson.plugins.sonar.SonarPublisher.executeSonar(SonarPublisher.java:213) at hudson.plugins.sonar.SonarPublisher.perform(SonarPublisher.java:177) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:372) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:360) at… Read More »