java.lang.NullPointerException

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.

  • This code works: {code:java} public class Entity { @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String col1; public String getCol1() { return col1; } @PrimaryKeyColumn(ordinal = 1) private String col2; public String getCol2() { return col2; } } {code} This code doesn't: {code:java} public class Entity { private String col1; @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) public String getCol1() { return col1; } private String col2; @PrimaryKeyColumn(ordinal = 1) public String getCol2() { return col2; } } {code} Exception is: {noformat} java.lang.NullPointerException at org.springframework.data.cassandra.mapping.CassandraPrimaryKeyColumnAnnotationComparator.compare(CassandraPrimaryKeyColumnAnnotationComparator.java:46) at org.springframework.data.cassandra.mapping.CassandraPersistentPropertyComparator.compare(CassandraPersistentPropertyComparator.java:67) at org.springframework.data.cassandra.mapping.CassandraPersistentPropertyComparator.compare(CassandraPersistentPropertyComparator.java:29) at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) at java.util.TimSort.sort(TimSort.java:220) at java.util.Arrays.sort(Arrays.java:1512) at java.util.ArrayList.sort(ArrayList.java:1454) at java.util.Collections.sort(Collections.java:175) at org.springframework.data.mapping.model.BasicPersistentEntity.verify(BasicPersistentEntity.java:382) at org.springframework.data.cassandra.mapping.BasicCassandraPersistentEntity.verify(BasicCassandraPersistentEntity.java:196) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:317) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:276) at org.springframework.data.mapping.context.AbstractMappingContext.initialize(AbstractMappingContext.java:392) at org.springframework.data.cassandra.mapping.BasicCassandraMappingContext.initialize(BasicCassandraMappingContext.java:79) at org.springframework.data.mapping.context.AbstractMappingContext.afterPropertiesSet(AbstractMappingContext.java:382) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ... 119 more {noformat} This becomes a particular problem when the Entity is in a class hierarchy, as methods can be overridden but fields cannot.
    via by James Howe,
  • This code works: {code:java} public class Entity { @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private String col1; public String getCol1() { return col1; } @PrimaryKeyColumn(ordinal = 1) private String col2; public String getCol2() { return col2; } } {code} This code doesn't: {code:java} public class Entity { private String col1; @PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) public String getCol1() { return col1; } private String col2; @PrimaryKeyColumn(ordinal = 1) public String getCol2() { return col2; } } {code} Exception is: {noformat} java.lang.NullPointerException at org.springframework.data.cassandra.mapping.CassandraPrimaryKeyColumnAnnotationComparator.compare(CassandraPrimaryKeyColumnAnnotationComparator.java:46) at org.springframework.data.cassandra.mapping.CassandraPersistentPropertyComparator.compare(CassandraPersistentPropertyComparator.java:67) at org.springframework.data.cassandra.mapping.CassandraPersistentPropertyComparator.compare(CassandraPersistentPropertyComparator.java:29) at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) at java.util.TimSort.sort(TimSort.java:220) at java.util.Arrays.sort(Arrays.java:1512) at java.util.ArrayList.sort(ArrayList.java:1454) at java.util.Collections.sort(Collections.java:175) at org.springframework.data.mapping.model.BasicPersistentEntity.verify(BasicPersistentEntity.java:382) at org.springframework.data.cassandra.mapping.BasicCassandraPersistentEntity.verify(BasicCassandraPersistentEntity.java:196) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:317) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:276) at org.springframework.data.mapping.context.AbstractMappingContext.initialize(AbstractMappingContext.java:392) at org.springframework.data.cassandra.mapping.BasicCassandraMappingContext.initialize(BasicCassandraMappingContext.java:79) at org.springframework.data.mapping.context.AbstractMappingContext.afterPropertiesSet(AbstractMappingContext.java:382) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ... 119 more {noformat} This becomes a particular problem when the Entity is in a class hierarchy, as methods can be overridden but fields cannot.
    via by James Howe,
    • java.lang.NullPointerException at org.springframework.data.cassandra.mapping.CassandraPrimaryKeyColumnAnnotationComparator.compare(CassandraPrimaryKeyColumnAnnotationComparator.java:46) at org.springframework.data.cassandra.mapping.CassandraPersistentPropertyComparator.compare(CassandraPersistentPropertyComparator.java:67) at org.springframework.data.cassandra.mapping.CassandraPersistentPropertyComparator.compare(CassandraPersistentPropertyComparator.java:29) at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) at java.util.TimSort.sort(TimSort.java:220) at java.util.Arrays.sort(Arrays.java:1512) at java.util.ArrayList.sort(ArrayList.java:1454) at java.util.Collections.sort(Collections.java:175) at org.springframework.data.mapping.model.BasicPersistentEntity.verify(BasicPersistentEntity.java:382) at org.springframework.data.cassandra.mapping.BasicCassandraPersistentEntity.verify(BasicCassandraPersistentEntity.java:196) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:317) at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:276) at org.springframework.data.mapping.context.AbstractMappingContext.initialize(AbstractMappingContext.java:392) at org.springframework.data.cassandra.mapping.BasicCassandraMappingContext.initialize(BasicCassandraMappingContext.java:79) at org.springframework.data.mapping.context.AbstractMappingContext.afterPropertiesSet(AbstractMappingContext.java:382) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    No Bugmate found.