A few days ago I was going through a project's Maven dependencies, removing unused junk, checking jar file version numbers adding a little dependency management and generally tidying up (yes, I know that this isn't something we often get time to do, but even Maven dependencies can be a form of technical debt). After recompiling and running the unit tests I ran some end to end tests only to find that the whole thing fell apart... Big time.
The exception I got was the usual one that all Spring developers get, a
Captain Debug's Blog
Java tips, observations, bugs and problems from the world of Spring, Weblogic, Oracle, MySQL and many other technologies...
Monday, 20 May 2013
Monday, 13 May 2013
Spring MVC, Ajax and JSON Part 3 - The Client Side Code
If you’ve been following this short series of blogs on Spring, Ajax and JSON you’ll recall that I’ve got as far as creating a Spring MVC web application that displays a form, which allows the user to select a bunch of items and submit a request to the server to purchase them. The server then replies with some JSON allowing the user to confirm their purchases. If you already know all this you can now jump to HERE. If you’re wondering what I’m talking about then take a look at the first two blogs in this series:
Having completed the server side code then the next thing to do is to move on to the client side code,
- Spring MVC, Ajax and JSON Part 1 - Setting The Scene
- Spring MVC, Ajax and JSON Part 2 - The Server Side Code
HERE
Having completed the server side code then the next thing to do is to move on to the client side code,
Labels:
Ajax,
Annotations,
Java,
Javascript,
JQuery,
JSON,
JSP,
Spring
Monday, 6 May 2013
Spring MVC, Ajax and JSON Part 2 - The Server Side Code
In my last blog I said that I was going to talk about Spring, Ajax and JSON, but didn't. The reason for this is that I wanted to set the scene using a (barely) credible shopping web site scenario. In this scenario when the user clicks on the eCommerce page link, the server app loads some the items from a catalogue and displays them on the page. The user then checks a number of items and presses 'Confirm Purchase'. Now, this is where Ajax and JSON come in, on pressing 'Confirm Purchase' the browser makes an Ajax request to the server sending it the item ids. The server then retrieves the items from the database returns them as JSON to the browser. The browser then processes the JSON, displaying the items on he screen.
My last blog got as far as creating and displaying a form that presented a list of items from the imaginary catalogue to the user. This blog takes a look at the next step in the project: creating some JSON.
My last blog got as far as creating and displaying a form that presented a list of items from the imaginary catalogue to the user. This blog takes a look at the next step in the project: creating some JSON.
Labels:
Ajax,
Annotations,
Java,
Javascript,
JQuery,
JSON,
JSP,
Spring
Monday, 29 April 2013
Spring MVC, Ajax and JSON Part 1 - Setting The Scene
I've been thinking about writing a blog on Spring, Ajax and JSON for a good while, but I've never got around to it. This was mainly because it was quite complicated and the technique required has been in a state of flux. When I decided to write this blog, I had a scout around the Internet and if you look on places such as Stack Overflow you'll see many different and often contradictory answers to the question "how do I write a Spring Ajax/JSON application?" I think that this is fault of the Guys at Spring in that they've been really busy improving Spring's support for JSon; not only that the Guys at JQuery have also been busy, which means that overall things have changed dramatically over the last couple of years and the answers to this "how do I write a Spring Ajax/JSON application?" are out of date.
Labels:
Ajax,
Annotations,
Java,
Javascript,
JQuery,
JSON,
JSP,
Spring
Monday, 22 April 2013
Five Ways of Synchronising Multithreaded Integration Tests
A few weeks ago I wrote a blog on synchronizing multithreaded integration tests, which was republished on DZone Javalobby from where it received a comment from Robert Saulnier who quite rightly pointed out that you can also use join() to synchronize a worker thread and its unit tests. This got me thinking, just how many ways can you synchronise multi-threaded integration tests? So, I started counting...
Monday, 15 April 2013
Just What Are Spring 3.2 Matrix Variables? - Part 2: The Code
My last blog on Spring's support for Matrix Variables concentrated on explaining what they were and why you'd want to use them. Having sorted out the what and the why, this blog is all about the how and how you use them. I also gave several examples of Matrix URIs and so, it seems good idea to demonstrate some code that processes a couple of them.
Labels:
Annotations,
Java,
Matrix Variables,
Spring,
Spring 3.2
Monday, 8 April 2013
Does Defensive Programming Deserve Such a Bad Name?
The other day I went to an hour's talk on erlang, merely as an observer; I know nothing about erlang except that it does sound interesting and that the syntax is... well... unusual. The talk was given to some Java programmers who had recently learnt erlang and was a fair critic about their first erlang project, which they were just completing. The presenter said that these programmers needed to stop thinking like Java programmers and start thinking like erlang programmers1 and in particular to stop programming defensively and let processes fail fast and fix the problem.
Now, apparently, this is good practice in erlang because one of the features of erlang, and please correct me if I'm wrong, is that work is split into supervisors and processes. Supervisors supervise processes, creating them, destroying them and restarting them if required. The idea of failing fast is nothing new and is defined as the technique to use when your code comes across an illegal input. When this happens your code just falls over and aborts the point being that you fix the supplier of that input rather than your code. The sub-text of what the presenter said is that Java and defensive programming is bad and fail-fast if good, which is something that really needs closer investigation.
Labels:
Defensive Programming,
Exceptions,
Fail Fast,
Java,
Null,
Validation,
Validator
Tuesday, 2 April 2013
Just What Are Spring 3.2 Matrix Variables? - Part 1
Spring 3.2 introduced support for processing something called 'Matrix Variables' and probably like most developers, I've never heard of them. So, after some research, this blog is my understanding of what they are and what you can do with them. As usual, please feel free to correct me if I'm wrong.
When I first read about them a whole bunch of questions came to mind, for example:
When I first read about them a whole bunch of questions came to mind, for example:
- What are they?
- Why use them?
- Why do the Guys at Spring think they're important?
- Why now?
Labels:
Ajax,
Annotations,
JSON,
Matrix Variables,
Specifications,
Spring,
Spring 3.2
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…
Labels:
Annotations,
Exceptions,
Java,
MVC,
Spring,
Spring 3.2
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.
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.
Labels:
Exceptions,
POM,
Spring,
Spring 3.2,
Upgrade
Subscribe to:
Posts (Atom)
