1

I am trying to call Rest service using RestTemplate (Spring 4.2.x.Release & + versions). I am also using Jackson 2.7.0 with it but i keep on getting exception. I have tested my webservice using Chrome PostMan it works perfectly.

Java Line code :

String response = template.postForObject(url,map, String.class);

Exception thrown:

Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.TypeFactory.constructType(Ljava/lang/reflect/Type;Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/JavaType;
    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.getJavaType(AbstractJackson2HttpMessageConverter.java:314)
    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:146)
    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:141)
    at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:706)
    at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:770)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:594)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557)
    at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:357)
usman
  • 1,351
  • 5
  • 23
  • 47
  • 1
    Possible duplicate of [Spring 4.2.3 and fasterxml Jackson 2.7.0 are incompatible](https://stackoverflow.com/questions/34721851/spring-4-2-3-and-fasterxml-jackson-2-7-0-are-incompatible) – Michael Peacock Oct 13 '17 at 13:51
  • following your comment, it still fails to work with those combinations. I have even tried latest version of both and it failed. may be i am missing some thing? – usman Oct 13 '17 at 14:00
  • I have found the issue. Problem is with Eclipse IDE as it is malfunctioning, i tried same code on NetBeans and it worked without any change. – usman Oct 14 '17 at 05:14

0 Answers0