[ROO-3589] web mvc json all creates json controllers for wrong @id property name Created: 12/Feb/15  Updated: 12/Feb/15

Status: Open
Project: Spring Roo
Component/s: None
Affects Version/s: 1.2.5.RELEASE, 1.3.1.RELEASE
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Andreas Kohlbecker Assignee: Enrique Ruiz (DiSiD)
Resolution: Unresolved Votes: 0
Labels: roo
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

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)

Attachments: Zip Archive jacq_input.scheme.zip     Zip Archive roo-backup.zip    
Reference URL: http://stackoverflow.com/questions/28435771/spring-roo-creates-json-controllers-for-wrong-id-property-name


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)

Generated at Sun Jul 12 07:40:41 UTC 2020 using Jira 8.5.4#805004-sha1:0444eab799707f9ad7b248d69f858774aadfd250.