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!