Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7559035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:31:55+00:00 2026-05-30T12:31:55+00:00

I have some problems with new version of Spring. I am doing something wrong

  • 0

I have some problems with new version of Spring. I am doing something wrong or I forget any configuration.

Concretly, I am doing a PoC of Restful service with Spring MVC. In Spring 3.0.3 runs correctly but in Spring 3.1 or 3.1.1 doesn’t run.

My PoC contains:

Controller:

@Controller
public class ProductControllerImpl implements IProductController {

private static Product producto = new Product();

@RequestMapping(value = "/products", method = RequestMethod.GET)
@ResponseBody
public List<Product> getAllProducts() {
    producto.setId(1L);
    List<Product> list = new ArrayList<Product>();
    list.add(producto);
    return list;
}

@RequestMapping(value = "/products/{productId}", method = RequestMethod.GET)
@ResponseBody
public Product getProductById(Long productId) {
    producto.setId(1L);     
    return producto;
}

}

ApplicationContext.xml:

<context:component-scan base-package="es.gerardribas.example.controller"/>

<bean id="xstreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller"/>

<bean id="marshallingHttpMessageConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
    <property name="marshaller" ref="xstreamMarshaller"/>
    <property name="unmarshaller" ref="xstreamMarshaller"/>
</bean>

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
        <util:list id="beanList">
            <ref bean="marshallingHttpMessageConverter"/>
        </util:list>
    </property>
</bean>

<mvc:annotation-driven/>

And web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>restservice</display-name>
  <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/applicationContext.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>restservice</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value></param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>restservice</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
</web-app>

In Spring 3.0.3 runs but in 3.1.1 doesn’t run.

This is the console log:

11:44:50,527 DEBUG btpool0-0 servlet.DispatcherServlet:845 - DispatcherServlet with name 'restservice' determining Last-Modified value for [/restservice/products/1]
11:44:50,528 DEBUG btpool0-0 annotation.DefaultAnnotationHandlerMapping:266 - Matching patterns for request [/products/1] are [/products/{productId}]
11:44:50,528 DEBUG btpool0-0 annotation.DefaultAnnotationHandlerMapping:290 - URI Template variables for request [/products/1] are {productId=1}
11:44:50,528 DEBUG btpool0-0 annotation.DefaultAnnotationHandlerMapping:221 - Mapping [/products/1] to handler 'es.gerardribas.example.controller.impl.ProductControllerImpl@2ee7e5'
11:44:50,528 DEBUG btpool0-0 servlet.DispatcherServlet:861 - Last-Modified value for [/restservice/products/1] is: -1
11:44:50,529 DEBUG btpool0-0 servlet.DispatcherServlet:693 - DispatcherServlet with name 'restservice' processing GET request for [/restservice/products/1]
11:44:50,530 DEBUG btpool0-0 support.HandlerMethodInvoker:172 - Invoking request handler method: public es.gerardribas.example.common.domain.Product es.gerardribas.example.controller.impl.ProductControllerImpl.getProductById(java.lang.Long)
11:44:50,531 DEBUG btpool0-0 annotation.AnnotationMethodHandlerAdapter:942 - Written [es.gerardribas.example.common.domain.Product@e634bf] as "application/xhtml+xml" using [org.springframework.http.converter.xml.MarshallingHttpMessageConverter@43b5bb]
11:44:50,531 DEBUG btpool0-0 servlet.DispatcherServlet:808 - Null ModelAndView returned to DispatcherServlet with name 'restservice': assuming HandlerAdapter completed request handling
11:44:50,532 DEBUG btpool0-0 servlet.DispatcherServlet:674 - Successfully completed request

And this 3.1.1 doesn’t run:

11:43:29,528 DEBUG btpool0-0 servlet.DispatcherServlet:819 - DispatcherServlet with name 'restservice' processing GET request for [/restservice/products/1]
11:43:29,528 DEBUG btpool0-0 annotation.RequestMappingHandlerMapping:213 - Looking up handler method for path /products/1
11:43:29,529 DEBUG btpool0-0 annotation.RequestMappingHandlerMapping:220 - Returning handler method [public es.gerardribas.example.common.domain.Product es.gerardribas.example.controller.impl.ProductControllerImpl.getProductById(java.lang.Long)]
11:43:29,530 DEBUG btpool0-0 support.DefaultListableBeanFactory:245 - Returning cached instance of singleton bean 'productControllerImpl'
11:43:29,530 DEBUG btpool0-0 servlet.DispatcherServlet:902 - Last-Modified value for [/restservice/products/1] is: -1
11:43:29,531 DEBUG btpool0-0 annotation.ExceptionHandlerExceptionResolver:132 - Resolving exception from handler [public es.gerardribas.example.common.domain.Product es.gerardribas.example.controller.impl.ProductControllerImpl.getProductById(java.lang.Long)]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
11:43:29,531 DEBUG btpool0-0 annotation.ResponseStatusExceptionResolver:132 - Resolving exception from handler [public es.gerardribas.example.common.domain.Product es.gerardribas.example.controller.impl.ProductControllerImpl.getProductById(java.lang.Long)]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
11:43:29,531 DEBUG btpool0-0 support.DefaultHandlerExceptionResolver:132 - Resolving exception from handler [public es.gerardribas.example.common.domain.Product es.gerardribas.example.controller.impl.ProductControllerImpl.getProductById(java.lang.Long)]: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
11:43:29,532 DEBUG btpool0-0 servlet.DispatcherServlet:957 - Null ModelAndView returned to DispatcherServlet with name 'restservice': assuming HandlerAdapter completed request handling
11:43:29,532 DEBUG btpool0-0 servlet.DispatcherServlet:913 - Successfully completed request

Anyone knows that I am doing wrong?

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:31:57+00:00Added an answer on May 30, 2026 at 12:31 pm

    In Spring 3.1, the <mvc:annotation-driven> element enables the new annotated controller support classes — see the what’s new section in the reference documentation. In effect your AnnotationMethodHandlerAdapter is ignored. You can replace it with RequestMappingHandlerAdapter or alternatively consider using the MVC Java config where it’s easier to customize the HandlerAdapter properly. See the section on configuring Spring MVC in the reference docs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some problems with rowspan: var doc1 = new Document(); doc1.SetPageSize(PageSize.A4.Rotate()); string path
I am very new to C and I have some problems learning about pointers.
I am using the new ASP control Chart, but I have some problems with
I have some problems sending mails through SMTP using Spring's MailSender interface and the
im new in hibernate and JPA and i have some problems with annotations. My
i am new in JSP,i have some problem with the following code : <%@
I have a problem at some customer pc's (new Dell PCs) windows XP Professional
I have some problems with Miktex installed on Windows Vista Business SP1/32 bit. I
I have some problems on a site with the concurrent access to a list.
I have some problems with OpenCV s cvCanny(...) and the Image data types it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.