3
votes

I am new to Spring and I am starting to learn it from his website. Understanding Java is not difficult to me, but I have trouble with the environment. I followed this guide for using Spring Boot for creating a new project and everything went great https://spring.io/guides/gs/spring-boot/

Now I would like to run this project from the Spring Tool Suite but I get this error when I try to run the same code on Pivotal or Tomcat server.

Failed to instantiate [org.springframework.boot.autoconfigure.web.HttpMessageConverters]: >Factory method 'messageConverters' threw exception; nested exception is java.lang.NoClassDefFoundError:org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverter

Any help from Spring developers for fixing my workflow?

2
The project you build from that guide should be run from the main method (not in a server), so I'm not sure how you got that to work. The classpath error looks like it wouldn't be possible if you followed the guide to the letter either. Does it work if you download the whole project and import it? (Also I recommend using the maven version to get started because it has more sane defaults for the classpath, and the Eclipse support is better.) - Dave Syer

2 Answers

1
votes

When you try to run the project via a server, first build it using maven so that all the dependencies are downloaded. This helps to download MappingJackson2XmlHttpMessageConverter class also. After building it deploy the war you create into the server.

1
votes

This class is added to spring from 4.1. You have to add

compile('org.springframework:spring-web:4.1.4.RELEASE')

for gradle, or

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>4.1.4.RELEASE</version>
</dependency>

for maven.