Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-3589

web mvc json all creates json controllers for wrong @id property name



    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.2.5.RELEASE, 1.3.1.RELEASE
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:
      Linux ubuntu Linux 3.13.0-45-generic

      java version "1.6.0_34"
      OpenJDK Runtime Environment (IcedTea6 1.13.6) (6b34-1.13.6-1ubuntu0.14.04.1)
      OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)


      I am reverse engineering an existing mysql database scheme. Everything works well except the web mvc json all command creates in some cases *_Roo_Controller_Json.aj files which refer to a non existent JPA Entity getter: getId(). This seems to occur in cases where the field annotated with @Id is having a different name than id. Strangely this problem not always occurs when I create the application from scratch by executing the whole roo script (posted below).

      The aspectj coompilation errors occure when the procet is compiled within the STS or by maven. Cleaning the target folder and starting the roo console afterwards is not causing any errors to pop up at the console.

      The JPA Entity ITD looks like:

      privileged aspect FrmwrkAuthItem_Roo_Jpa_Entity {
          declare @type: FrmwrkAuthItem: @Entity;
          declare @type: FrmwrkAuthItem: @Table(name = "frmwrk_AuthItem");
          @GeneratedValue(strategy = GenerationType.AUTO)
          @Column(name = "name", length = 64)
          private String FrmwrkAuthItem.name;
          public String FrmwrkAuthItem.getName() {
              return this.name;
          public void FrmwrkAuthItem.setName(String id) {
              this.name = id;

      The web mvc json all command creates the file FrmwrkAuthItemController_Roo_Controller_Json.aj with a createFromJson() method in which the non existing getter getId() is used (code simplified).

      privileged aspect FrmwrkAuthItemController_Roo_Controller_Json {
          @RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json")
          public ResponseEntity<String> FrmwrkAuthItemController.createFromJson(@RequestBody String json, UriComponentsBuilder uriBuilder) {
              HttpHeaders headers = new HttpHeaders();
              headers.add("Content-Type", "application/json");
              try {
                  FrmwrkAuthItem frmwrkAuthItem = FrmwrkAuthItem.fromJsonToFrmwrkAuthItem(json);
                  RequestMapping a = (RequestMapping) getClass().getAnnotation(RequestMapping.class);
                   * below is the corrupt line of code with frmwrkAuthItem.getId()
                   * frmwrkAuthItem.getName() would be correct! 
                  return new ResponseEntity<String>(headers, HttpStatus.CREATED);
              } catch (Exception e) {
                  return new ResponseEntity<String>("{\"ERROR\":"+e.getMessage()+"\"}", headers, HttpStatus.INTERNAL_SERVER_ERROR);

      Attached to this ticket is a backup of the roo project wich additionally also conatains a console.log file showing the compilation errors reported by the maven aspectj plugin. The attachemnt jacq_input.scheme.zip contains the database scheme on which the project is based on (created by database introspect)




            eruiz Enrique Ruiz (DiSiD)
            akohlbecker Andreas Kohlbecker
            0 Vote for this issue
            1 Start watching this issue