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

Error thrown when generating the *DataOnDemand classes when using a constant value as a size specifier in the @Size annotation of an Entity

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.0.RELEASE
    • Fix Version/s: None
    • Component/s: TESTING
    • Environment:
      Windows 7, Java 6, Spring 3.1.0

      Description

      I have a common jar file with classes like

      • User,
      • Group,
      • Permission,

      that is shared between 5 projects and the data is passed between all applications via web services.

      I have defined in these classes a inner class called Metadata that describes the classes i.e.

      • Field names,
      • Field sizes
      • Web Service end points

      This helps the other applications perform validation before passing the User object.
      I then want to use this metadata to describe the object to Hibernate and Spring, so I tried setting the @Size annotation for the fields.
      Hibernate is happy to use the Static fields, so is Spring.
      The applications compile and run.
      However Roo is not happy to generate the DataOnDemand classes for entities configured this way.

      Below are examples of what i am doing, and what roo is out-putting
      I have attached a ZIP file with a very very small Spring/Roo project

      Should kick off the error simply by extracting, then opening a roo console within the project roo

      User.java
      package au.com.finalconcept.annotation.usingconst.domain;
      
      import javax.validation.constraints.Size;
      import org.springframework.roo.addon.javabean.RooJavaBean;
      import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
      import org.springframework.roo.addon.tostring.RooToString;
      
      @RooJavaBean
      @RooToString
      @RooJpaActiveRecord
      public class User {
      
          public static final int MIN_SIZE = 3;
      
          @Size(min = MIN_SIZE, max = 60)
          private String username;
      }
      
      Roo.exe
      [Spring Roo Process Manager Background Polling Thread] org.springframework.roo.model.EnumDetails cannot be cast to java.lang.Integer
        java.lang.ClassCastException: org.springframework.roo.model.EnumDetails cannot be cast to java.lang.Integer
        at org.springframework.roo.addon.dod.DataOnDemandMetadata.getFieldInitializer(DataOnDemandMetadata.java:1013)
        at org.springframework.roo.addon.dod.DataOnDemandMetadata.<init>(DataOnDemandMetadata.java:149)
        at org.springframework.roo.addon.dod.DataOnDemandMetadataProviderImpl.getMetadata(DataOnDemandMetadataProviderImpl.java:181)
        at org.springframework.roo.classpath.itd.AbstractItdMetadataProvider.get(AbstractItdMetadataProvider.java:324)
        at org.springframework.roo.metadata.DefaultMetadataService.getInternal(DefaultMetadataService.java:150)
        at org.springframework.roo.metadata.DefaultMetadataService.evictAndGet(DefaultMetadataService.java:285)
        at org.springframework.roo.classpath.itd.AbstractItdMetadataProvider.notify(AbstractItdMetadataProvider.java:158)
        at org.springframework.roo.metadata.DefaultMetadataService.notify(DefaultMetadataService.java:240)
        at org.springframework.roo.metadata.internal.DefaultMetadataDependencyRegistry.notifyDownstream(DefaultMetadataDependencyRegistry.java:191)
        at org.springframework.roo.classpath.DefaultPhysicalTypeMetadataProvider.onFileEvent(DefaultPhysicalTypeMetadataProvider.java:97)
        at org.springframework.roo.file.monitor.polling.PollingFileMonitorService.publish(PollingFileMonitorService.java:350)
        at org.springframework.roo.file.monitor.polling.PollingFileMonitorService.scanAll(PollingFileMonitorService.java:323)
        at org.springframework.roo.process.manager.internal.DefaultProcessManager.doTransactionally(DefaultProcessManager.java:181)
        at org.springframework.roo.process.manager.internal.DefaultProcessManager.backgroundPoll(DefaultProcessManager.java:128)
        at org.springframework.roo.process.manager.internal.DefaultProcessManager.timerBasedPoll(DefaultProcessManager.java:243)
        at org.springframework.roo.process.manager.internal.DefaultProcessManager$2.run(DefaultProcessManager.java:71)
        at java.lang.Thread.run(Unknown Source)
      

      P.s. Is there a switch to enable logging in Roo? Took around 3 hours to find what the cause was.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            adam.g.pullen Adam Pullen
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated: