facebook

Spring RESTFUL resturned 406 Not Acceptable

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #526917 Reply

    eugenejsn
    Participant

    ME 2017 Windows 7.

    Followed the guide https://www.genuitec.com/spring-frameworkrestcontroller-vs-controller/.

    Returned 406 Not Acceptable error.

    Spring: 4.1.1.Release

    POM.xml

    First tried:

    <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.8.9</version>
    </dependency>
    <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.8.9</version>
    </dependency>
    <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.8.9</version>
    </dependency>

    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-mapper-asl</artifactId>
    <version>1.9.13</version>
    </dependency>
    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-core-asl</artifactId>
    <version>1.9.13</version>
    </dependency>

    –Did not work.

    Then upgraded to

    <dependency>
    <groupId>com.fasterxml.jackson.jaxrs</groupId>
    <artifactId>jackson-jaxrs-base</artifactId>
    <version>2.8.9</version>
    </dependency>

    web-servlet.xml

    <mvc:annotation-driven>
    <mvc:message-converters>
    <bean class=”org.springframework.http.converter.StringHttpMessageConverter”/>
    <bean class=”org.springframework.http.converter.json.MappingJackson2HttpMessageConverter”/>
    </mvc:message-converters>
    </mvc:annotation-driven>

    Also tried:

    <mvc:annotation-driven />

    <bean class=”org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter”>
    <property name=”messageConverters”>
    <list>
    <ref bean=”jacksonMessageConverter”/>
    </list>
    </property>
    </bean>
    <bean id=”jacksonMessageConverter” class=”org.springframework.http.converter.json.MappingJackson2HttpMessageConverter”></bean>

    or

    <bean id=”contentNegotiationManager” class=”org.springframework.web.accept.ContentNegotiationManagerFactoryBean”>
    <property name=”favorPathExtension” value=”false” />
    <property name=”favorParameter” value=”true” />
    <property name=”mediaTypes” >
    <value>
    json=application/json
    xml=application/xml
    </value>
    </property>
    </bean>

    None worked.

    Looks like there were mismatching among versions of the JACKSON, Spring, and message-converters. But which version works with which?

    Eugene

    • This topic was modified 7 years, 6 months ago by eugenejsn.
    #526974 Reply

    support-swapna
    Moderator

    Eugene,

    I am afraid this is a Spring development related query. I suggest you cross post to development related forums like stackoverflow.com for better suggestions from the developer community.

    –Swapna
    MyEclipse Support

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Spring RESTFUL resturned 406 Not Acceptable

You must be logged in to post in the forum log in