java.lang.NullPointerException: null

DataStax JIRA | Arnaud Roger | 1 year ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  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

    Loader NPEs in com.datastax.driver.core.BoundStatement.bind

    GitHub | 1 year ago | KenMcK1
    java.util.concurrent.ExecutionException: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      null

      at com.datastax.driver.core.BoundStatement.bind()
    2. DataStax Java Driver for Apache Cassandra - Core
      DefaultPreparedStatement.bind
      1. com.datastax.driver.core.BoundStatement.bind(BoundStatement.java:209)
      2. com.datastax.driver.core.DefaultPreparedStatement.bind(DefaultPreparedStatement.java:103)
      2 frames
    3. org.sfm.datastax
      SettableDataMapperTest.checkObjectInserted
      1. org.sfm.datastax.SettableDataMapperTest.checkObjectInserted(SettableDataMapperTest.java:45)
      1 frame