java.lang.ClassCastException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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 {code:title=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; } {code} {code:title=Roo.exe|borderStyle=solid} [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) {code} P.s. Is there a switch to enable logging in Roo? Took around 3 hours to find what the cause was.
    via by Adam Pullen,
  • 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 {code:title=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; } {code} {code:title=Roo.exe|borderStyle=solid} [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) {code} P.s. Is there a switch to enable logging in Roo? Took around 3 hours to find what the cause was.
    via by Adam Pullen,
    • 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)
    No Bugmate found.