I am working with Redis(via redisson) I have a DTO class that I am serializing an deserializing into Redis,
the codec I am using is:
org.redisson.codec.FstCodec
when I move the class to a diffrent namespace despite setting the: serialVersionUID explicitly in the DTO class in class I get the following exception:
java.io.IOException: java.lang.RuntimeException: class not found CLASSNAME:db.data.coins.CoinDTO loader:jdk.internal.loader.ClassLoaders$AppClassLoader@6ed3ef1
In the example I moved the class from package:
db.data.coins.CoinDTO
to package:
dto
Link to fstCodec github:
package dto; // altering package
import java.io.Serializable;
import java.sql.Timestamp;
public class CoinDTO implements Serializable {
static final long serialVersionUID = 1L;
private int id;
private double amount;
private Timestamp timestamp;
//Getters and setters
}
I would like to alter the package and still get the class from Redis.
Many thanks in advance
P.S
The way I am currently handling it is by serializing of the object using json and then setting it into redis, but that is just double serialization and I would like to avoid that
when I move the class to a diffrent namespace despite setting the: serialVersionUID explicitly in the DTO class in class I get the following exception:
You can't deserialize object if its package or class name has changed.
The way I am currently handling it is by serializing of the object using json and then setting it into redis
You could set Redisson to Jackson as follow codec = org.redisson.codec.JsonJacksonCodec