ArangoDB、Java、Velocypack 尝试反序列化 DBEntity 时出错 [英] ArangoDB, Java, Velocypack error trying to deserialize a DBEntity

查看:24
本文介绍了ArangoDB、Java、Velocypack 尝试反序列化 DBEntity 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 SpringBoot 1.5.4.RELEASE、ArangoDB java 驱动程序 4.5.0、Arango Spring Data 1.1.5

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

我还没有找到根本原因(仍在寻找)但我可以看到错误在哪里被抛出,在 VPack 类中有这个方法

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;
}

但传入的类型是接口 com.arangodb.springframework.core.convert.DBEntity.没有为此创建者,并且它不是参数化类型,因此调用 newInstance.这当然失败了.

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.

这似乎源自 find 方法中的 ArangoTemplate.这是传入 DBEntity.class 的地方.

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.

谢谢,
西蒙

推荐答案

这通常不应该发生,因为存在一个 用于 DBEntity 的 VPackDeseralizer.你可能覆盖了 AbstractArangoConfiguration.arangoTemplate() 吗?在这种情况下,您已经删除了底层驱动程序所需的配置.

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.

这篇关于ArangoDB、Java、Velocypack 尝试反序列化 DBEntity 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆