ArangoDB, Java, Velocypack error trying to deserialize a DBEntity

▼魔方 西西 提交于 2019-12-24 18:42:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!