Sunday, 16 October 2016

Spring Boot Crashing Due to Unsatisfied Depedency?

We've just had a report of a possible bug on our Microservices course - your web application might fail to start up with something like the following in the Stacktrace:

Launcher.java:49) [spring-boot-devtools-1.4.1.RELEASE.jar:1.4.1.RELEASE]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'positionTrackingExternalService': Unsatisfied dependency expressed through field 'remoteService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.virtualpairprogrammers.services.RemotePositionMicroserviceCalls': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException

This will happen if you use Spring boot 1.4 - the original course code used Boot 1.3.

So, as a quick (and unsatisfactory) fix, you can drop the version of boot down to 1.3. However, the root course appears to be classloader related (I haven't had time to fully investigate it, although the bug report here gives a big clue) and is triggered by the presence of the devtools dependency. We added that back on the first course to enable automatic container reloading.

Boot maintains two classloaders, and on a change to the code, it only needs to restart one - this is a speed optimisation. I have no idea why this break has happened in Boot 1.4, but if you have this problem, the solution is to remove the spring-boot-devtools dependency from your POM and all will be well. Of course, you'll now need to manually bounce the server each time you make changes.

If I get time to investigate this more thoroughly, I'll make further posts but hopefully for now this will stop anybody hitting a brick wall on the course!

Wednesday, 12 October 2016

Spring Boot Microservices

Here's the opening chapter from the new Microservices course. As always I talk far....toooo.....slowly...... so you can hit the speed up button!

Full closed captions/subtitles are available on the full course from the VirtualPairProgrammers.com site.

Thursday, 6 October 2016

Microservices with Spring Boot: Release Date October 11 2016

Microservices - it's nearly here!

We're approaching the end of an intense, exhausting but fun few weeks recording the new release, Microservices with Spring Boot. I'll put up a proper announcement with a preview video when it's finally out.

In the meantime, a few words about the thought process behind the course: whilst internally at VirtualPairProgrammers, we use Kubernetes for much of the orchestration of the microservices, we wanted a course that would integrate closely with our Spring and Spring Boot lines, which took us down the path of using Spring Cloud.

Spring Cloud, as you'll see on the course, is a superb collection of components, mainly derived from the work done at Netflix, which offers features such as service discovery, load balancing, fail safety/cirtcuit breaking and so on.

Whether you want to use Spring Cloud or not, the course is an in-depth starter to microservices. You'll be managing a small set of microservices which collaborate to provide a vehicle tracking front end:

What's In?

  1. An introduction to Microservices
  2. Messaging with ActiveMq
  3. Running a Microservice Architecture
  4. Service Discovery with Netflix Eureka
  5. Client Side Load Balancing with Ribbon
  6. Circuit Breakers with Hystrix
  7. Declarative REST with Feign
  8. Spring Cloud Config Server

What's out?

This is only a "getting started", and I realise that the course ends at a point where there are still many questions to answer. Mainly, how to deploy the architecture to live hardware - as discussed in previous blog posts, automating the entire workflow is so important.

For this course, I wanted life to be as simple as possible - the downside of this is that it did mean running a lot of Microservices locally (all in separate eclipse workspaces), and a lot of faffing stopping/starting queues, etc. In a way, I hope this helps - it should make people realise that managing microservices is much harder than managing a monolith.

This was a hard decision to make for this course - I wanted it to be as production grade as possible (read: not a hello world app), without it being daunting and off putting. I think at certain points in the course, it does get hard when we're constantly switching from one microservice to the next, stopping and starting services and generally trying to juggle several things at once. All of this in a true production would be automated and scripted - but I didn't want that to get in the way of the learning.

So there will be a follow on, where we use configuration management to automate the deployment to live hardware (it will be AWS as that's what we're comfortable with). We'll also use Virtual Machines to allow developers to run full production rigs on local development machines.

Also missing from this course, which I very much wanted to include, were Spring Cloud Bus (Automatic re-distribution of system wide properties) and Zuul (API gateway); these were lost mainly due to timescale pressures, and that the sample system couldn't really support their use. We'll be looking at these topics in the very near future.

Also, since this is a fast moving area, I expect that we will have to update the course in the near future anyway, so we'll be releasing much more on this topic soon!

The "Microservices part 2: Automating Deployment" (working title) is aimed to be out late November/early December. It'll feature Ansible, Docker (probably) and lots of automated AWS provisioning, including a healthy slice of AWS Lambda. Can't wait!