Announcement Announcement Module
No announcement yet.
Error: The attribute produces is undefined for the annotation type RequestMapping Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error: The attribute produces is undefined for the annotation type RequestMapping

    I haven't had the need to run the Roo Shell for a while on my project until today when I decided to refactor the Entity references in my project. I recently F&R'ed (Format'ed and Reseed'ed) my laptop, re-installing the latest STS and Roo. I believe prior I was at Roo 1.2.1rc1, and the latest 2.9 STS upgraded from a 2.8 install.

    Anyhow, after my pretty major refactor was done, all my Controllers now how the following errors in the aspect files:
    The attribute produces is undefined for the annotation type RequestMapping
    Its on all the methods in the xxxController_Roo_Controller.aj files on the following annotations:
    @RequestMapping(method = RequestMethod.POST, produces = "text/html")
    I know when I cranked up the Roo Shell, I saw this:
    Updated ROOT/pom.xml [updated property 'roo.version' to '1.2.1.RELEASE'; updated property 'spring.version' to '3.1.0.RELEASE'; updated property 'roo.version' to '1.2.1.RELEASE'; updated property 'spring.version' to '3.1.0.RELEASE']
    But, I checked the @RequestMapping javadoc on the SpringSource site, and it shows produces as a valid member of the annotation.

    Anyone have a clue where I can look to fix this?

  • #2
    Never mind...when it updated the POM, it updated the Spring JAR versions, but didn't refresh the Eclipse project files. I ran a perform eclipse on it, refreshed, and all the errors are gone.


    • #3

      I was trying to integrate Ajax using jQuery to make a POST request to Spring controller. However I am getting the following error in controller.

      "The attribute consumes is undefined for the annotation type RequestMapping"

      ​I am using spring 3.0.5 jars.

      I came across your post on the forum regarding similar issue. Can you please help?

      HTML code:

          div {
                  border: 1px solid #000000;
          <script src="/JSONProject/js/jquery-1.11.0.min.js"></script>
          var user="";
          var pwd1="";
          var json="";
          var strJson="";
                      console.log("inside click");
                      console.log("json: "+json);
                      console.log("strJson: "+strJson);
                           type: "POST",
                            url: "http://localhost:8080/JSONProject/add.html",
                            contentType: 'application/json',
                            data: JSON.stringify(json)
                        .done(function(resultUserDTO) {
                            alert("result: "+resultUserDTO);
                  Please enter your text:
                      <div  >
                          <label id="uName">Username</label>
                          <input id="userName"/>
                          <label id="pwd">Password</label>
                          <input id="password" type="Password" id="pwd"/>
                  <INPUT id="button" TYPE="SUBMIT" VALUE="Submit">
      Controller code:

      package demo.controller;
      import org.springframework.stereotype.Controller;
      import org.springframework.web.bind.annotation.RequestBody;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RequestMethod;
      import org.springframework.web.bind.annotation.ResponseBody;
      import org.springframework.web.servlet.ModelAndView;
      import demo.model.Login;
      public class HelloWorldController {
          Login users;
          public ModelAndView helloWorld() {
              String message = "Hello World, Spring 3.0!";
              System.out.println("Inside controller");
              return new ModelAndView("hello", "message", message);
           * Handles request for adding two numbers
          @RequestMapping(value = "/add",method = RequestMethod.POST,consumes = "application/json")
          public String processJson(@RequestBody String requestBody){
              return "Handled application/json request ";
      Last edited by maybeam; Mar 28th, 2014, 05:21 AM.


      • #4
        solved this issue by using 3.2.0 spring jar.
        Points learned:

        1. consumes/produces are not available for @RequestMapping in 3.0.x
        2. when using 3.2.0, asm jar is not required.