问题
I'm using SpringBoot 1.5.4.RELEASE, ArangoDB java driver 4.5.0, Arango Spring Data 1.1.5
I'm getting this error when retrieving an object.
com.arangodb.velocypack.exception.VPackParserException: java.lang.InstantiationException: com.arangodb.springframework.core.convert.DBEntity
I can't find the root cause yet (still looking) but I can see where the error is being thrown, in the class VPack there is this method
private <T> T createInstance(final Type type) throws InstantiationException, IllegalAccessException {
final T entity;
final VPackInstanceCreator<?> creator = instanceCreators.get(type);
if (creator != null) {
entity = (T) creator.createInstance();
} else if (type instanceof ParameterizedType) {
entity = createInstance(((ParameterizedType) type).getRawType());
} else {
entity = ((Class<T>) type).newInstance();
}
return entity;
}
but the type being passed in is the interface com.arangodb.springframework.core.convert.DBEntity
. There is no creator for this, and it is not a parameterized type, so newInstance is called. This of course fails.
This seems to originate from ArangoTemplate
in the find method. Here is where DBEntity.class is being passed in.
@Override
public <T> Optional<T> find(final String id, final Class<T> entityClass, final DocumentReadOptions options)
throws DataAccessException {
try {
final DBEntity doc = _collection(entityClass, id).getDocument(determineDocumentKeyFromId(id),
DBEntity.class, options);
return Optional.ofNullable(fromDBEntity(entityClass, doc));
} catch (final ArangoDBException e) {
throw translateExceptionIfPossible(e);
}
}
I am trying to create a test that will produce this on demand. If I succeed I will post here.
thanks,
Simon
回答1:
this should normally not happen, because there exists a VPackDeseralizer for DBEntity. Do you maybe have overridden AbstractArangoConfiguration.arangoTemplate()
? In this case you have removed the needed configuration of the underlying driver.
来源:https://stackoverflow.com/questions/50869309/arangodb-java-velocypack-error-trying-to-deserialize-a-dbentity