apache / incubator-hugegraph

A graph database that supports more than 100+ billion data, high performance and scalability (Include OLTP Engine & REST-API & Backends)
https://hugegraph.apache.org
Apache License 2.0
2.66k stars 520 forks source link

[Bug] get exception when connecting to HugeGraph #2040

Open JasonQi2020 opened 2 years ago

JasonQi2020 commented 2 years ago

Bug Type (问题类型)

other exception / error (其他异常报错)

Before submit

Environment (环境信息)

Expected & Actual behavior (期望与实际表现)

the following code complains:

 GraphTraversalSource g = traversal().withRemote("\resources\\remote.properties");
  org.apache.tinkerpop.gremlin.structure.Vertex next = g.V().next();
 System.out.println(next);

exception

java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

at org.apache.tinkerpop.gremlin.process.remote.RemoteConnection.from(RemoteConnection.java:73)
at org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.withRemote(AnonymousTraversalSource.java:76)
at org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.withRemote(AnonymousTraversalSource.java:66)
at com.blackwings.hugegraph.dao.HugegraphTest.con3(HugegraphTest.java:153)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.apache.tinkerpop.gremlin.process.remote.RemoteConnection.from(RemoteConnection.java:71) ... 27 more Caused by: java.lang.VerifyError: Bad type on operand stack Exception Details: Location: com/baidu/hugegraph/io/HugeGraphSONModule.registerCommonSerializers(Lorg/apache/tinkerpop/shaded/jackson/databind/module/SimpleModule;)V @58: invokespecial Reason: Type 'com/baidu/hugegraph/date/SafeDateFormat' (current frame, stack[5]) is not assignable to 'java/text/DateFormat' Current Frame: bci: @58 flags: { } locals: { 'org/apache/tinkerpop/shaded/jackson/databind/module/SimpleModule', integer } stack: { 'org/apache/tinkerpop/shaded/jackson/databind/module/SimpleModule', 'java/lang/Class', uninitialized 47, uninitialized 47, 'java/lang/Boolean', 'com/baidu/hugegraph/date/SafeDateFormat' } Bytecode: 0000000: 2a12 0fbb 0010 59b7 0011 b600 1257 2a12 0000010: 13bb 0014 59b7 0015 b600 1257 2a12 16bb 0000020: 0017 59b7 0018 b600 1257 033c 2a12 19bb 0000030: 001a 591b b800 1bb2 001c b700 1db6 0012 0000040: 572a 1219 bb00 1e59 bb00 1e59 b700 1fb2 0000050: 001c 1220 b700 21b6 0022 572a 1223 bb00 0000060: 2459 b700 25b6 0012 572a 1223 bb00 2659 0000070: b700 27b6 0022 572a 1228 bb00 2959 b700 0000080: 2ab6 0012 572a 1228 bb00 2b59 b700 2cb6 0000090: 0022 57b1

at com.baidu.hugegraph.io.HugeGraphIoRegistry.<init>(HugeGraphIoRegistry.java:36)
at com.baidu.hugegraph.io.HugeGraphIoRegistry.<clinit>(HugeGraphIoRegistry.java:27)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1.lambda$configure$0(GraphBinaryMessageSerializerV1.java:108)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1.configure(GraphBinaryMessageSerializerV1.java:106)
at org.apache.tinkerpop.gremlin.driver.Settings$SerializerSettings.lambda$create$0(Settings.java:425)
at java.base/java.util.Optional.ifPresent(Optional.java:183)
at org.apache.tinkerpop.gremlin.driver.Settings$SerializerSettings.create(Settings.java:425)
at org.apache.tinkerpop.gremlin.driver.Cluster.getBuilderFromSettings(Cluster.java:224)
at org.apache.tinkerpop.gremlin.driver.Cluster.build(Cluster.java:172)
at org.apache.tinkerpop.gremlin.driver.Cluster.open(Cluster.java:260)
at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection.<init>(DriverRemoteConnection.java:80)
... 32 more

configration file :

remote.properties

gremlin.remote.remoteConnectionClass=org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection gremlin.remote.driver.clusterFile=remote-objects.yaml gremlin.remote.driver.sourceName=g

remote-objects.yaml

hosts: [1.320.5.220] port: 8182 serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1, config: { ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry] } }

Vertex/Edge example (问题点 / 边数据举例)

No response

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

No response

javeme commented 1 year ago

可以参考下类似问题:

JasonQi2020 commented 1 year ago

Thanks for your answer. I tried to follow the solutions that you recommended , but unfortunately it still doesn't work.

could you please help me check my configuration ? Thanks.
I am using the 3.5.2.

        <dependency>
            <groupId>com.baidu.hugegraph</groupId>
            <artifactId>hugegraph-core</artifactId>
            <version>0.11.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-core</artifactId>
            <version>3.5.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>tinkergraph-gremlin</artifactId>
            <version>3.5.2</version>
        </dependency>

            <groupId>org.apache.tinkerpop</groupId>
            <artifactId>gremlin-driver</artifactId>
            <version>3.5.2</version>
            <scope>test</scope>
        </dependency>

local file remote-objects.yaml , I added serializeResultToString :true

hosts: [1.220.205.20]
port: 8182
serializer: {
  className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
  config: {
    serializeResultToString: true ,
    ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
  }
}

Server gremlin-server.yaml


host: 127.0.0.1
port: 8182
scriptEvaluationTimeout: 30000

channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
        }

scriptEngines: {
  gremlin-groovy: {
    plugins: {
      com.baidu.hugegraph.plugin.HugeGraphGremlinPlugin: {},
      org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
      org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
        classImports: [
          java.lang.Math,
          com.baidu.hugegraph.backend.id.IdGenerator,
          com.baidu.hugegraph.type.define.Directions,
          com.baidu.hugegraph.type.define.NodeRole,
          com.baidu.hugegraph.traversal.algorithm.CollectionPathsTraverser,
          com.baidu.hugegraph.traversal.algorithm.CountTraverser,
          com.baidu.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
          com.baidu.hugegraph.traversal.algorithm.CustomizePathsTraverser,
          com.baidu.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
          com.baidu.hugegraph.traversal.algorithm.HugeTraverser,
          com.baidu.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
          com.baidu.hugegraph.traversal.algorithm.KneighborTraverser,
          com.baidu.hugegraph.traversal.algorithm.KoutTraverser,
          com.baidu.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
          com.baidu.hugegraph.traversal.algorithm.NeighborRankTraverser,
          com.baidu.hugegraph.traversal.algorithm.PathsTraverser,
          com.baidu.hugegraph.traversal.algorithm.PersonalRankTraverser,
          com.baidu.hugegraph.traversal.algorithm.SameNeighborTraverser,
          com.baidu.hugegraph.traversal.algorithm.ShortestPathTraverser,
          com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
          com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser,
          com.baidu.hugegraph.traversal.algorithm.TemplatePathsTraverser,
          com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep,
          com.baidu.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
          com.baidu.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
          com.baidu.hugegraph.traversal.optimize.Text,
          com.baidu.hugegraph.traversal.optimize.TraversalUtil,
          com.baidu.hugegraph.util.DateUtil
        ],
        methodImports: [java.lang.Math#*]
      },
      org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
        files: [scripts/empty-sample.groovy]
      }
    }
  }
}
serializers:
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
      config: {
        serializeResultToString: false,
        ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
      }
  }
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
      config: {
        serializeResultToString: true,
        ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
      }
  }
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0,
      config: {
        serializeResultToString: true,
        ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
      }
  }
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
      config: {
        serializeResultToString: true,
        ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
      }
  }
metrics: {
  consoleReporter: {enabled: false, interval: 180000},
  csvReporter: {enabled: false, interval: 180000, fileName: ./metrics/gremlin-server-metrics.csv},
  jmxReporter: {enabled: false},
  slf4jReporter: {enabled: false, interval: 180000},
  gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
  graphiteReporter: {enabled: false, interval: 180000}
}

my JAVA code

     Cluster cluster = Cluster.open("D:\\Work\\resources\\remote-objects.yaml");
        Client client = cluster.connect();

        try {
            ResultSet results = client.submit("hugegraph.traversal().V()");
            results.stream().forEach(result -> {
                System.out.println(result.getVertex());
            });

            results = client.submit("hugegraph.traversal().E()");
            results.stream().forEach(result -> {
                System.out.println(result.getEdge());
            });
        } finally {
            client.close();
            cluster.close();
        }

    }

the exception is still the same ........

java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    com/baidu/hugegraph/io/HugeGraphSONModule.registerCommonSerializers(Lorg/apache/tinkerpop/shaded/jackson/databind/module/SimpleModule;)V @58: invokespecial
  Reason:
    Type 'com/baidu/hugegraph/date/SafeDateFormat' (current frame, stack[5]) is not assignable to 'java/text/DateFormat'
  Current Frame:
    bci: @58
    flags: { }
    locals: { 'org/apache/tinkerpop/shaded/jackson/databind/module/SimpleModule', integer }
    stack: { 'org/apache/tinkerpop/shaded/jackson/databind/module/SimpleModule', 'java/lang/Class', uninitialized 47, uninitialized 47, 'java/lang/Boolean', 'com/baidu/hugegraph/date/SafeDateFormat' }
  Bytecode:
    0000000: 2a12 0fbb 0010 59b7 0011 b600 1257 2a12
    0000010: 13bb 0014 59b7 0015 b600 1257 2a12 16bb
    0000020: 0017 59b7 0018 b600 1257 033c 2a12 19bb
    0000030: 001a 591b b800 1bb2 001c b700 1db6 0012
    0000040: 572a 1219 bb00 1e59 bb00 1e59 b700 1fb2
    0000050: 001c 1220 b700 21b6 0022 572a 1223 bb00
    0000060: 2459 b700 25b6 0012 572a 1223 bb00 2659
    0000070: b700 27b6 0022 572a 1228 bb00 2959 b700
    0000080: 2ab6 0012 572a 1228 bb00 2b59 b700 2cb6
    0000090: 0022 57b1                              

    at com.baidu.hugegraph.io.HugeGraphIoRegistry.<init>(HugeGraphIoRegistry.java:36)
    at com.baidu.hugegraph.io.HugeGraphIoRegistry.<clinit>(HugeGraphIoRegistry.java:27)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at org.apache.tinkerpop.gremlin.driver.ser.AbstractMessageSerializer.lambda$addIoRegistries$0(AbstractMessageSerializer.java:50)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    at org.apache.tinkerpop.gremlin.driver.ser.AbstractMessageSerializer.addIoRegistries(AbstractMessageSerializer.java:48)
    at org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0.configure(AbstractGraphSONMessageSerializerV1d0.java:76)
    at org.apache.tinkerpop.gremlin.driver.Settings$SerializerSettings.lambda$create$0(Settings.java:425)
    at java.base/java.util.Optional.ifPresent(Optional.java:183)
    at org.apache.tinkerpop.gremlin.driver.Settings$SerializerSettings.create(Settings.java:425)
    at org.apache.tinkerpop.gremlin.driver.Cluster.getBuilderFromSettings(Cluster.java:224)
    at org.apache.tinkerpop.gremlin.driver.Cluster.build(Cluster.java:172)
    at org.apache.tinkerpop.gremlin.driver.Cluster.open(Cluster.java:263)
    at com.blackwings.hugegraph.dao.HugegraphTest.con3(HugegraphTest.java:126)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)