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!

9 thoughts on “Spring Boot Crashing Due to Unsatisfied Depedency?”

    1. I think it’s just an autogenerated database – you might have to create a record or something I can’t remember exactly, depends on where you are in the video. Why not send in a support request through the contact page a virtualpairprogrammers.com – give a video timestamp or chapter number if you can!

  1. To be host i find the code in chapter for very difficult to follow and i do not know why in this course you did not do it as all other course i think you should have walk through the code to make student understand it

    1. To be honest back, I’ve no idea what chapter you’re referring to. However walking through code to make the students understand is my job – not a problem, VirtualPairProgrammers have a very fair and open refund policy, just contact them and get your money back.

  2. My MISTAKE I’m Speaking about chapter 4 in Spring Boot Microservices course, I did NOT Ask for my money back.
    BASICALLY YOU ARE ONE OF THE BEST COURSES PROVIDER EVER The code i’m referring to is the code in PostionSimulatorApplication

    1. Ah I see – yes I recall that Simulator is a bit of a throwaway piece of code. Honestly I’d be embarrassed to talk through that implementation – it’s definitely not a production standard piece of code, it’s intended as a quick and dirty test simulator type thing. IIRC I spin up multiple threads to simulate different vehicles going at different speeds and my threading is terrible (especially the closing down)! Hope it didn’t spoil the course too much!

Leave a Reply

Your email address will not be published. Required fields are marked *