Facing strange problem. Object is inserted successfully. when I try to read it in the same project, getting error
com.aerospike.client.AerospikeException$Serialize: Error Code -1: java.lang.ClassNotFoundException: model.test.TestEntity
at com.aerospike.client.command.Buffer.bytesToObject(Buffer.java:321)
at com.aerospike.client.command.Buffer.bytesToParticle(Buffer.java:63)
at com.aerospike.client.command.ReadCommand.parseRecord(ReadCommand.java:174)
at com.aerospike.client.command.ReadCommand.parseResult(ReadCommand.java:116)
at com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:56)
at com.aerospike.client.AerospikeClient.get(AerospikeClient.java:481)
.......
Caused by: java.lang.ClassNotFoundException: model.test.TestEntity
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
at com.aerospike.client.command.Buffer.bytesToObject(Buffer.java:318)
... 47 more
Here is the code. Trying it in play2.3.
TestEntity testEntity = new TestEntity();
testEntity.setId("1");
testEntity.setName("testEntity");
BusinessRelation br = new BusinessRelation();
br.setEntityId("1");
br.setRelationType("R");
List<BusinessRelation> brList = new ArrayList<BusinessRelation>();
brList.add(br);
testEntity.setRelationList(brList);
WritePolicy policy = new WritePolicy();
Key key = new Key("test", "testtable", Value.get("test"));
Bin data = new Bin("tc1", testEntity);
ClientPolicy clientPolicy = new ClientPolicy();
try {
AerospikeClient client = new AerospikeClient(clientPolicy, new Host("localhost", 3000));
client.put(policy, key, data);
Record record =client.get(policy,key);//getting error here
} catch (Exception e) {
e.printStackTrace();
}
inside package model.test;
public class TestEntity implements Serializable
{
public String id;
public String name;
public List<BusinessRelation> relationList;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public List<BusinessRelation> getRelationList() {
return relationList;
}
public void setRelationList(List<BusinessRelation> relationList) {
this.relationList = relationList;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
inside package model;
public class BusinessRelation implements java.io.Serializable {
String relationType;
String entityId;
public String getRelationType() {
return relationType;
}
public void setRelationType(String relationType) {
this.relationType = relationType;
}
public String getEntityId() {
return entityId;
}
public void setEntityId(String entityId) {
this.entityId = entityId;
}
}
my dev evn windows 7,aerospike with vm, play2.3, latest aerospike-client