Problem with Spring Boot Starter Web and FasterXML Jackson dependency

While working with Spring Boot and developing a combined REST/JSON & SOAP/XML (not sexy, I know) API I was able to build & compile but on runtime I had this error:


Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
ERROR 2145 --- [ main] o.s.boot.SpringApplication : Application startup failed
..........
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ...........
...........
...........
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException

So Spring uses Jackson and the Jackson library is composed of three components: Jackson Databind, Core, and Annotation. I did not add anything specific to my maven pom.xml for Jackson so the dependency got inherited somewhere. So after some Google jobs I figured out the spring-boot-starter-parent uses some older FasterXML/Jackson libs which seem to screw things up.


jvzoggel$ mvn dependency:tree -Dincludes=com.fasterxml.jackson.*

[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ springboot ---
[INFO] nl.rubix.api:springboot:jar:0.0.1-SNAPSHOT
[INFO] - org.springframework.boot:spring-boot-starter-web:jar:1.5.10.RELEASE:compile
[INFO] - com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO] - com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile

So by overriding the dependency in my pom.xml I could make sure a newer version of Jackson was used:

<!-- Jackson due to SpringBootStarterParent dependency problems -->
<dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-databind</artifactId>
   <version>2.9.4</version>
</dependency>
<dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-core</artifactId>
   <version>2.9.4</version>
</dependency>
<dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-annotations</artifactId>
   <version>2.9.4</version>
</dependency>

Problem solved.

References