Idea创建HugeGraph属性报IllegalArgumentException

一、错误内容

java.lang.reflect.UndeclaredThrowableException
    at com.sun.proxy.$Proxy28.create(Unknown Source)
    at com.meiyijia.pd.flink.hugeGraph.SingleExample.main(SingleExample.java:26)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.baidu.hugegraph.structure.schema.BuilderProxy.invoke(BuilderProxy.java:56)
    ... 2 more
Caused by: class java.lang.IllegalArgumentException: The name of property key can't be null
    at com.baidu.hugegraph.exception.ServerException.fromResponse(ServerException.java:47)
    at com.baidu.hugegraph.client.RestClient.checkStatus(RestClient.java:93)
    at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:198)
    at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:172)
    at com.baidu.hugegraph.api.schema.PropertyKeyAPI.create(PropertyKeyAPI.java:46)
    at com.baidu.hugegraph.driver.SchemaManager.addPropertyKey(SchemaManager.java:79)
    at com.baidu.hugegraph.structure.schema.PropertyKey$BuilderImpl.create(PropertyKey.java:142)
    at com.baidu.hugegraph.structure.schema.PropertyKey$BuilderImpl.create(PropertyKey.java:125)
    ... 7 more

二、报错场景

  使用schema创建属性Key后报错

public static void main(String[] args) throws IOException {
        HugeClient hugeClient = null;
        try {
            // If connect failed will throw a exception.
            hugeClient = HugeClient.builder("http://192.168.66.83:8080",
                    "meta_hugegraph")
                    .build();

            SchemaManager schema = hugeClient.schema();
            schema.propertyKey("aaa3").asText().valueSingle().ifNotExist().create();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            hugeClient.close();
        }

    }

三、解决

  fastjson依赖冲突导致,将依赖替换为1.1.X版本即可,我这边替换为1.1.45版本后,再次运行就好了

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.1.45</version>
</dependency>

  参考地址:https://github.com/apache/incubator-hugegraph/issues/5

posted @ 2022-05-12 17:14  宜家数据小哥  阅读(169)  评论(0编辑  收藏  举报