java.lang.NullPointerException: null

DataStax JIRA | Arnaud Roger | 1 year ago
  1. 0

    The static initialisation order of the inner class in TypeCodec are not garanteed, and sometimes that causes the primitiveCodecs map to be initialised before LongCodec.instance is. it happens on oracle java8 travid ci build box, but if I ran that {code} public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { Class<?> longCodec = Class.forName("com.datastax.driver.core.TypeCodec$LongCodec"); Field f = Class.forName("com.datastax.driver.core.TypeCodec").getDeclaredField("primitiveCodecs"); f.setAccessible(true); System.out.println("primitiveCodecs = " + f.get(null)); } {code} then it happens all the time {code} primitiveCodecs = {ascii=com.datastax.driver.core.TypeCodec$StringCodec@2e0fa5d3, bigint=null, blob=com.datastax.driver.core.TypeCodec$BytesCodec@5010be6, boolean=com.datastax.driver.core.TypeCodec$BooleanCodec@685f4c2e, counter=null, decimal=com.datastax.driver.core.TypeCodec$DecimalCodec@7daf6ecc, double=com.datastax.driver.core.TypeCodec$DoubleCodec@2e5d6d97, float=com.datastax.driver.core.TypeCodec$FloatCodec@238e0d81, inet=com.datastax.driver.core.TypeCodec$InetCodec@31221be2, int=com.datastax.driver.core.TypeCodec$IntCodec@377dca04, text=com.datastax.driver.core.TypeCodec$StringCodec@728938a9, timestamp=com.datastax.driver.core.TypeCodec$DateCodec@21b8d17c, uuid=com.datastax.driver.core.TypeCodec$UUIDCodec@6433a2, varchar=com.datastax.driver.core.TypeCodec$StringCodec@728938a9, varint=com.datastax.driver.core.TypeCodec$BigIntegerCodec@5910e440, timeuuid=com.datastax.driver.core.TypeCodec$TimeUUIDCodec@6267c3bb, custom=com.datastax.driver.core.TypeCodec$BytesCodec@5010be6} {code} the primitiveCodecs should not depends on the static initialisers, it could instead create the instance itself. during the build I then get the following error {code} testInsertDbObjects(org.sfm.datastax.SettableDataMapperTest) Time elapsed: 0.089 sec <<< ERROR! java.lang.NullPointerException: null at com.datastax.driver.core.BoundStatement.bind(BoundStatement.java:209) at com.datastax.driver.core.DefaultPreparedStatement.bind(DefaultPreparedStatement.java:103) at org.sfm.datastax.SettableDataMapperTest.checkObjectInserted(SettableDataMapperTest.java:45) {code} or {code} testMapSetUDT(org.sfm.datastax.DatastaxMapperCollectionTest) Time elapsed: 0.331 sec <<< ERROR! java.lang.NullPointerException: null at com.datastax.driver.core.DataType.deserialize(DataType.java:673) at com.datastax.driver.core.AbstractData.hashCode(AbstractData.java:457) at com.datastax.driver.core.UDTValue.hashCode(UDTValue.java:69) at java.util.HashMap.hash(HashMap.java:338) at java.util.HashMap.put(HashMap.java:611) at java.util.HashSet.add(HashSet.java:219) at com.datastax.driver.core.TypeCodec$SetCodec.deserialize(TypeCodec.java:1076) at com.datastax.driver.core.TypeCodec$SetCodec.deserialize(TypeCodec.java:1001) at com.datastax.driver.core.AbstractGettableByIndexData.getSet(AbstractGettableByIndexData.java:343) at com.datastax.driver.core.AbstractGettableData.getSet(AbstractGettableData.java:26) at org.sfm.datastax.impl.getter.DatastaxSetWithConverterGetter.get(DatastaxSetWithConverterGetter.java:24) at org.sfm.datastax.impl.getter.DatastaxSetWithConverterGetter.get(DatastaxSetWithConverterGetter.java:10) at org.sfm.map.impl.fieldmapper.FieldMapperImpl.mapTo(FieldMapperImpl.java:23) {code} see https://travis-ci.org/arnaudroger/SimpleFlatMapper/jobs/83902196

    DataStax JIRA | 1 year ago | Arnaud Roger
    java.lang.NullPointerException: null
  2. 0

    The static initialisation order of the inner class in TypeCodec are not garanteed, and sometimes that causes the primitiveCodecs map to be initialised before LongCodec.instance is. it happens on oracle java8 travid ci build box, but if I ran that {code} public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { Class<?> longCodec = Class.forName("com.datastax.driver.core.TypeCodec$LongCodec"); Field f = Class.forName("com.datastax.driver.core.TypeCodec").getDeclaredField("primitiveCodecs"); f.setAccessible(true); System.out.println("primitiveCodecs = " + f.get(null)); } {code} then it happens all the time {code} primitiveCodecs = {ascii=com.datastax.driver.core.TypeCodec$StringCodec@2e0fa5d3, bigint=null, blob=com.datastax.driver.core.TypeCodec$BytesCodec@5010be6, boolean=com.datastax.driver.core.TypeCodec$BooleanCodec@685f4c2e, counter=null, decimal=com.datastax.driver.core.TypeCodec$DecimalCodec@7daf6ecc, double=com.datastax.driver.core.TypeCodec$DoubleCodec@2e5d6d97, float=com.datastax.driver.core.TypeCodec$FloatCodec@238e0d81, inet=com.datastax.driver.core.TypeCodec$InetCodec@31221be2, int=com.datastax.driver.core.TypeCodec$IntCodec@377dca04, text=com.datastax.driver.core.TypeCodec$StringCodec@728938a9, timestamp=com.datastax.driver.core.TypeCodec$DateCodec@21b8d17c, uuid=com.datastax.driver.core.TypeCodec$UUIDCodec@6433a2, varchar=com.datastax.driver.core.TypeCodec$StringCodec@728938a9, varint=com.datastax.driver.core.TypeCodec$BigIntegerCodec@5910e440, timeuuid=com.datastax.driver.core.TypeCodec$TimeUUIDCodec@6267c3bb, custom=com.datastax.driver.core.TypeCodec$BytesCodec@5010be6} {code} the primitiveCodecs should not depends on the static initialisers, it could instead create the instance itself. during the build I then get the following error {code} testInsertDbObjects(org.sfm.datastax.SettableDataMapperTest) Time elapsed: 0.089 sec <<< ERROR! java.lang.NullPointerException: null at com.datastax.driver.core.BoundStatement.bind(BoundStatement.java:209) at com.datastax.driver.core.DefaultPreparedStatement.bind(DefaultPreparedStatement.java:103) at org.sfm.datastax.SettableDataMapperTest.checkObjectInserted(SettableDataMapperTest.java:45) {code} or {code} testMapSetUDT(org.sfm.datastax.DatastaxMapperCollectionTest) Time elapsed: 0.331 sec <<< ERROR! java.lang.NullPointerException: null at com.datastax.driver.core.DataType.deserialize(DataType.java:673) at com.datastax.driver.core.AbstractData.hashCode(AbstractData.java:457) at com.datastax.driver.core.UDTValue.hashCode(UDTValue.java:69) at java.util.HashMap.hash(HashMap.java:338) at java.util.HashMap.put(HashMap.java:611) at java.util.HashSet.add(HashSet.java:219) at com.datastax.driver.core.TypeCodec$SetCodec.deserialize(TypeCodec.java:1076) at com.datastax.driver.core.TypeCodec$SetCodec.deserialize(TypeCodec.java:1001) at com.datastax.driver.core.AbstractGettableByIndexData.getSet(AbstractGettableByIndexData.java:343) at com.datastax.driver.core.AbstractGettableData.getSet(AbstractGettableData.java:26) at org.sfm.datastax.impl.getter.DatastaxSetWithConverterGetter.get(DatastaxSetWithConverterGetter.java:24) at org.sfm.datastax.impl.getter.DatastaxSetWithConverterGetter.get(DatastaxSetWithConverterGetter.java:10) at org.sfm.map.impl.fieldmapper.FieldMapperImpl.mapTo(FieldMapperImpl.java:23) {code} see https://travis-ci.org/arnaudroger/SimpleFlatMapper/jobs/83902196

    DataStax JIRA | 1 year ago | Arnaud Roger
    java.lang.NullPointerException: null
  3. 0
    Elasticsearch 1.x and 2.x nodes are not compatible, make sure your setup contains nodes of the same major version.
    via GitHub by dakrone
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0
    It is a JDK bug, no workaround currently.
    via GitHub by jroper
  6. 0
    Some of the parametes ar enull

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      null

      at com.datastax.driver.core.DataType.deserialize()
    2. DataStax Java Driver for Apache Cassandra - Core
      UDTValue.hashCode
      1. com.datastax.driver.core.DataType.deserialize(DataType.java:673)
      2. com.datastax.driver.core.AbstractData.hashCode(AbstractData.java:457)
      3. com.datastax.driver.core.UDTValue.hashCode(UDTValue.java:69)
      3 frames
    3. Java RT
      HashSet.add
      1. java.util.HashMap.hash(HashMap.java:338)
      2. java.util.HashMap.put(HashMap.java:611)
      3. java.util.HashSet.add(HashSet.java:219)
      3 frames
    4. DataStax Java Driver for Apache Cassandra - Core
      AbstractGettableData.getSet
      1. com.datastax.driver.core.TypeCodec$SetCodec.deserialize(TypeCodec.java:1076)
      2. com.datastax.driver.core.TypeCodec$SetCodec.deserialize(TypeCodec.java:1001)
      3. com.datastax.driver.core.AbstractGettableByIndexData.getSet(AbstractGettableByIndexData.java:343)
      4. com.datastax.driver.core.AbstractGettableData.getSet(AbstractGettableData.java:26)
      4 frames
    5. org.sfm.datastax
      DatastaxSetWithConverterGetter.get
      1. org.sfm.datastax.impl.getter.DatastaxSetWithConverterGetter.get(DatastaxSetWithConverterGetter.java:24)
      2. org.sfm.datastax.impl.getter.DatastaxSetWithConverterGetter.get(DatastaxSetWithConverterGetter.java:10)
      2 frames
    6. org.sfm.map
      FieldMapperImpl.mapTo
      1. org.sfm.map.impl.fieldmapper.FieldMapperImpl.mapTo(FieldMapperImpl.java:23)
      1 frame