java.lang.IllegalArgumentException: Column metaclass does not exist in table users

DataStax JIRA | Alexandre Dutra | 6 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    From the [user mailing list|https://groups.google.com/a/lists.datastax.com/d/msg/java-driver-user/Hlf907jcWk0/CyXO2HGKCAAJ]: bq. We implement our @Table mappings as Groovy classes. This has worked fine with previous releases of the MappingManager thru release 3.0.3. With the latest 3.1.0 release, it appears MappingManager requires there to be a column defined for the Groovy MetaClass property. Comparing the source between 3.0.3 and 3.1.0, it looks like reflective inspection of the entity class has changed considerably within com.datastax.driver.mapping.AnnotationParser#parseEntity. The new 3.1.0 source utilizes com.datastax.driver.mapping.ReflectionUtils.scanFieldsAndProperties which picks up the MetaClass property. Creation of the Mapper fails since the actual table metadata does not include a corresponding column for the Groovy class's MetaClass. Indeed, a simple class such as {code} @Table(name = "users") class User { @PartitionKey @Column(name = "user_id") def UUID userId def String name } {code} Will fail with: {code} Exception in thread "main" java.lang.IllegalArgumentException: Column metaclass does not exist in table users at com.datastax.driver.mapping.AnnotationParser.parseEntity(AnnotationParser.java:131) at com.datastax.driver.mapping.MappingManager.getMapper(MappingManager.java:226) at com.datastax.driver.mapping.MappingManager.mapper(MappingManager.java:182) at com.datastax.driver.mapping.MappingManager$mapper.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at com.datastax.driver.mapping.User.main(User.groovy:42) {code} This is because Groovy adds a {{metaClass}} property to Groovy classes. The most simple fix is to explicitly exclude this property in {{ReflectionUtils}}. In the meanwhile, the following workaround seems to work: {code} @Transient def MetaClass metaClass = super.metaClass; {code}

    DataStax JIRA | 6 months ago | Alexandre Dutra
    java.lang.IllegalArgumentException: Column metaclass does not exist in table users

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Column metaclass does not exist in table users

      at com.datastax.driver.mapping.AnnotationParser.parseEntity()
    2. com.datastax.driver
      MappingManager$mapper.call
      1. com.datastax.driver.mapping.AnnotationParser.parseEntity(AnnotationParser.java:131)
      2. com.datastax.driver.mapping.MappingManager.getMapper(MappingManager.java:226)
      3. com.datastax.driver.mapping.MappingManager.mapper(MappingManager.java:182)
      4. com.datastax.driver.mapping.MappingManager$mapper.call(Unknown Source)
      4 frames
    3. Groovy
      AbstractCallSite.call
      1. org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      2. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      3. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      3 frames
    4. com.datastax.driver
      User.main
      1. com.datastax.driver.mapping.User.main(User.groovy:42)
      1 frame