IllegalStateException: Could not instantiate XmlMapper - not found on classpath




Asked on October 04, 2015
I am creating spring content negotiation application and using MappingJackson2XmlView class. While running URL with .xml, I am getting following error.

Caused by: java.lang.IllegalStateException: Could not instantiate XmlMapper - not found on classpath
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:517)
at org.springframework.web.servlet.view.xml.MappingJackson2XmlView.<init>(MappingJackson2XmlView.java:58)
at com.mycompany.config.AppConfiguration.configureViewResolvers(AppConfiguration.java:17)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurerComposite.configureViewResolvers(WebMvcConfigurerComposite.java:126)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration.configureViewResolvers(DelegatingWebMvcConfiguration.java:82)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.mvcViewResolver(WebMvcConfigurationSupport.java:820)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$d75efaf5.CGLIB$mvcViewResolver$35(<generated>)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration$$EnhancerBySpringCGLIB$$d75efaf5$$FastClassBySpringCGLIB$$f8085515.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)




Replied on October 04, 2015
You need jackson-dataformat-xml

For Gradle, use 

compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.6.2'

For maven, use

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.6.2</version>
</dependency>


Write Answer










©2024 concretepage.com | Privacy Policy | Contact Us