incubator-hugegraph icon indicating copy to clipboard operation
incubator-hugegraph copied to clipboard

执行demo报错 : The name of property key can't be null

Open Axlabo opened this issue 8 years ago • 5 comments

本地启动了hugegraph使用下面链接的demo执行 , 新建schema时报错 :
https://hugegraph.github.io/hugegraph-doc//quickstart/hugegraph-client.html

schema.propertyKey("name").asText().ifNotExist().create();
Caused by: com.baidu.hugegraph.exception.ServerException: The name of property key can't be null

逐一排查项目依赖 , 发现去掉对fastjson的依赖 , 或强制指定fastjson的依赖为1.1.x , 可以解决此问题 ;

我使用的hugegraph版本: client : 1.5.8 server : 0.7.4

复现此问题的方法 : 在上面demo项目里面加上对 fastjson 1.2.x 的依赖 : com.alibaba:fastjson:1.2.44

Axlabo avatar Aug 12 '18 05:08 Axlabo

感谢反馈,有空请close这个issue

Linary avatar Aug 13 '18 07:08 Linary

有用, 此外 和jackson-databind 也有冲突(具体版本没测试) 项目中去掉该依赖 加入 jackson-annotations(2.10.2) 问题解决

472732787 avatar Oct 19 '20 06:10 472732787

fastjson的冲突是因为1.2.36版本以上 实现了Jersey 的AutoDiscoverable 导致的,在工程启动类中把 FastJsonAutoDiscoverable的autoDiscover设置为false可以解决高版本fastjson冲突问题,

Ckuangf avatar May 26 '22 02:05 Ckuangf

如果更换了fastjson版本依然有问题,请尝试通过命令mvn dependency:tree查看具体冲突版本,然后尝试找到一个可兼容的中间版本。

javeme avatar Jul 05 '22 07:07 javeme

fastjson的冲突是因为1.2.36版本以上 实现了Jersey 的AutoDiscoverable 导致的,在工程启动类中把 FastJsonAutoDiscoverable的autoDiscover设置为false可以解决高版本fastjson冲突问题,

hugeclient与fastjson高版本(当前1.2.83,springboot 2.x, 图库1.0.0, 客户端1.0.0)整合报错问题,原因为:FastJsonAutoDiscoverable中javax.ws的包不存在问题。在工程中直接创建同名包,然后覆写代码,编译后会替换掉fastjson中的同名class,感谢 @小宇 同学。

package com.alibaba.fastjson.support.jaxrs;

import jakarta.ws.rs.core.FeatureContext;
import org.glassfish.jersey.internal.spi.AutoDiscoverable;

/**
 * @Title: FastJsonAutoDiscoverable
 * @Description: fastjson使用SPI在jvm中加载class,高版本与hugegraph结合使用时,并不存在javax.ws的包,
 * 	重写内容,编译后替换classpath中fastjson的同名class文件
 */
public class FastJsonAutoDiscoverable implements AutoDiscoverable {

    public static final String FASTJSON_AUTO_DISCOVERABLE = "fastjson.auto.discoverable";

    public volatile static boolean autoDiscover = true;

    static {
        try {
            autoDiscover = Boolean.parseBoolean(
                    System.getProperty(FASTJSON_AUTO_DISCOVERABLE, String.valueOf(autoDiscover)));
        } catch (Throwable ex) {
            //skip
        }
    }

    public void configure(final FeatureContext context) {

    }

}

dongma avatar Aug 05 '23 00:08 dongma