Monday, 25 March 2013

Exception Handling with the Spring 3.2 @ControllerAdvice Annotation

A short time ago, I wrote a blog outlining how I upgraded my Spring sample code to version 3.2 and demonstrating a few of the little 'gotchas' that arose. Since that I've been perusing Spring 3.2's new feature list and whilst it doesn't contain any revolutionary new changes, which I suspect the Guys at Spring are saving for version 4, it does contain a few neat upgrades. The first one that grabbed my attention was the new @ControllerAdvice annotation, which seems to neatly plug a gap in Spring 3 functionality. Let me explain…

Wednesday, 20 March 2013

Creating a Spring 3.2 MVC Web App

A couple of days ago, I wrote a blog outlining how I upgraded my Spring sample code to version 3.2.1-RELEASE and demonstrated a few of the little 'gotchas' that arose. One of those 'gotchas' involved a Spring ContentNegotiationManagerFactoryBean error and I demonstrated a fix that involved declaring the spring-web module in your POM file, rather than relying on its import as a transient dependency, which I'm guessing pulled in the wrong version.

Since than I've been perusing Spring 3.2's new feature list, deciding which I thought were useful and would also make good blogs. When writing a blog, the first thing I like to do is to create a working sample and so I decided to create a new Spring MVC project using the Spring Project Template feature on the SpringSource Dashboard.

Monday, 18 March 2013

Upgrading to Spring 3.2

A few days ago I thought that it was about time to upgrade my sample code to Spring 3.2, after all it’s been around for a respectable amount of time and even has a bug fix release.

Upgrading to Spring 3.2 is very simple matter of upgrading your Maven version number and rebuilding, something like this:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>3.2.1.RELEASE</version>
</dependency>

...for every Spring dependency and then recompiling

Monday, 11 March 2013

Producers and Consumers - Part 3 Poison Pills

A couple of weeks ago I wrote part 2 of a short series of blogs on the Producer Consumer pattern. This blog focused upon the need to close down my Teletype’s worker thread, fixing a bug in the original code from part 1 of the series.

The idea here is that the Teletype’s worker thread can be controlled by a command from the application’s main thread. This command tells the worker thread to shutdown thus allowing the app the gracefully shutdown as demonstrated by the code below:

Monday, 4 March 2013

Maven’s Non-resolvable parent POM Problem

I recently got an email from Nosheen Javed asking about an exception he was getting on his Maven build. The exception was:

[FATAL] Non-resolvable parent POM: Failure to find com.mycompany.samples:biometrics-samples:pom:4.2.0.0

...which when listed in full comes out as:

Apache Maven 3.0.4 (r1232337; 2012-01-17 13:44:56+0500)
Maven home: C:\Users\Nosheen\workspace\simple-fingers-sample\EMBEDDED
Java version: 1.7.0_07, vendor: Oracle Corporation
Java home: C:\Program Files (x86)\Java\jre7
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from EMBEDDED\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\Nosheen\.m2\settings.xml
[DEBUG] Using local repository at C:\Users\Nosheen\.m2\repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for C:\Users\Nosheen\.m2\repository
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]