Getting a ByteBuffer from Cassandra, NotSerializable error

29 Views Asked by At

I am writing a List of Class (lets say <classname>) object into a cassandra table by converting it into ByteBuffer using ObjectOutputStream -> ByteArrayOutputStream and then ByteBuffer.wrap(byteArrayInputStream.toByteArray()).

(It stores in form of 0xACED.....)

While retrieving the ByteBuffer from cassandra, I keep getting error "java.io.NotSerializableException: <classname>". The code I am using for the same is:

ByteBuffer bytebuff = row.getBb();
byte[] result = new byte[bytebuff.remaining()];
bytebuff.get(result);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(result);
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
List<<classname>> obj = (List<<classname>>) objectInputStream.readObject(); //this line throws the error

I tried googling alot but couldnt find any fixes, any inputs would be much apperitiated. PS: The class <classname> is declared with "implements Serializable".

0

There are 0 best solutions below