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.58k stars 512 forks source link

[Question] Error during serialization, serializer org.apache.hugegraph.backend.id.IdGenerator$StringId not found #2526

Closed kd1510 closed 2 months ago

kd1510 commented 2 months ago

Problem Type (问题类型)

None

Before submit

Environment (环境信息)

Your Question (问题描述)

Hello,

I have managed to get HugeGraph running via docker, and can connect to the server via the TinkerPop Java client. I'm getting serialization errors only for the ID, however, and I am able to fetch other labels etc. I have tried every combination of serializer on both the server and client side, nothing seems to work.

Config:

gremlin-server.yaml:

# host and port of gremlin server, need to be consistent with host and port in rest-server.properties
host: 0.0.0.0
port: 8182

# timeout in ms of gremlin query
evaluationTimeout: 30000

channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer

# don't set graph at here, this happens after support for dynamically adding graph
graphs: {
}
scriptEngines: {
  gremlin-groovy: {
    staticImports: [
      org.opencypher.gremlin.process.traversal.CustomPredicates.*',
      org.opencypher.gremlin.traversal.CustomFunctions.*
    ],
    plugins: {
      org.apache.hugegraph.plugin.HugeGraphGremlinPlugin: {},
      org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
      org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
        classImports: [
          java.lang.Math,
          org.apache.hugegraph.backend.id.IdGenerator,
          org.apache.hugegraph.type.define.Directions,
          org.apache.hugegraph.type.define.NodeRole,
          org.apache.hugegraph.masterelection.GlobalMasterInfo,
          org.apache.hugegraph.util.DateUtil,
          org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser,
          org.apache.hugegraph.traversal.algorithm.CountTraverser,
          org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
          org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser,
          org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
          org.apache.hugegraph.traversal.algorithm.HugeTraverser,
          org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
          org.apache.hugegraph.traversal.algorithm.KneighborTraverser,
          org.apache.hugegraph.traversal.algorithm.KoutTraverser,
          org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
          org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser,
          org.apache.hugegraph.traversal.algorithm.PathsTraverser,
          org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser,
          org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser,
          org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser,
          org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
          org.apache.hugegraph.traversal.algorithm.SubGraphTraverser,
          org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser,
          org.apache.hugegraph.traversal.algorithm.steps.EdgeStep,
          org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
          org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
          org.apache.hugegraph.traversal.optimize.ConditionP,
          org.apache.hugegraph.traversal.optimize.Text,
          org.apache.hugegraph.traversal.optimize.TraversalUtil,
          org.opencypher.gremlin.traversal.CustomFunctions,
          org.opencypher.gremlin.traversal.CustomPredicate
        ],
        methodImports: [
          java.lang.Math#*,
          org.opencypher.gremlin.traversal.CustomPredicate#*,
          org.opencypher.gremlin.traversal.CustomFunctions#*
        ]
      },
      org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
        files: [scripts/empty-sample.groovy]
      }
    }
  }
}
serializers:
  - {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
     config: {
       serializeResultToString: true,
       ioRegistries: [ com.apache.hugegraph.io.HugeGraphIoRegistry]
     }
  }
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0,
      config: {
        serializeResultToString: true,
        ioRegistries: [ org.apache.hugegraph.io.HugeGraphIoRegistry ]
      }
  }
  - {className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
     config: {
       serializeResultToString: true,
       ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
     }
  }
  - {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
     config: {
       serializeResultToString: true,
       ioRegistries: [org.apache.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}
}
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 65536
maxAccumulationBufferComponents: 1024
resultIterationBatchSize: 64
writeBufferLowWaterMark: 32768
writeBufferHighWaterMark: 65536
ssl: {
  enabled: false
}

remote-objects.yaml:

hosts: [localhost]
port: 8182
gremlin.remote.remoteConnectionClass: org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection
gremlin.remote.driver.sourceName: __g_hugegraph
serializer:
  - {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
     config: {
       serializeResultToString: true,
       ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
     }
  }

code:


import org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal

val g = traversal().withRemote("remote-objects.yaml")
g.V("78f9ff4f705c25ce722cc537614cc177cfc3179c").toList()  //Throws error Error during serialization, serializer org.apache.hugegraph.backend.id.IdGenerator$StringId not found

g.V("78f9ff4f705c25ce722cc537614cc177cfc3179c").label().toList() // Deserializes and returns labels fine from the server.

Any help appreciated!

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

No response

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

No response

dosubot[bot] commented 2 months ago

The error you're encountering, "Error during serialization, serializer org.apache.hugegraph.backend.id.IdGenerator$StringId not found," typically points to a serialization issue between the HugeGraph server and the TinkerPop Java client. This can arise from version incompatibilities or misconfigurations in serialization settings. Here's how to address it:

  1. Ensure Version Compatibility: Verify that the versions of the HugeGraph server and the TinkerPop Java client are compatible. Version mismatches can lead to serialization problems.

  2. Update Both Server and Client: If there's a version mismatch, update the HugeGraph server and the TinkerPop Java client to versions known to be compatible.

  3. Check Serializer Registration: Make sure any custom serializers are correctly registered on both the client and server. The documentation for HugeGraph and TinkerPop should guide you on how to do this.

  4. Review Configuration: Double-check your configuration settings for both the server and client to ensure all necessary serializers are enabled and properly set up.

  5. Dependencies: Confirm that your project includes all required dependencies to avoid missing class errors during serialization.

  6. Consult Documentation: Look into the HugeGraph and Apache TinkerPop documentation for any specific instructions or recommendations, especially regarding running HugeGraph with Docker on a Mac M1.

Addressing these points should help resolve the serialization error you're facing.

Sources

#### About Dosu This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
kd1510 commented 2 months ago

Backtrace:

java.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: Error during serialization: Serializer for type org.apache.hugegraph.backend.id.IdGenerator$StringId not found
    at java.base/java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:413)
    at java.base/java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2118)
    at org.apache.tinkerpop.gremlin.driver.ResultSet.one(ResultSet.java:123)
    at org.apache.tinkerpop.gremlin.driver.ResultSet$1.hasNext(ResultSet.java:175)
    at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:182)
    at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:169)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:115)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:100)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal.nextTraverser(DriverRemoteTraversal.java:92)
    at org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep.processNextStart(RemoteStep.java:80)
dosubot[bot] commented 2 months ago

First u could refer https://github.com/apache/incubator-hugegraph/issues/2036#issuecomment-1341043034 to help u use HugeGraph Gremlin query directly.


The serialization error you're encountering with org.apache.hugegraph.backend.id.IdGenerator$StringId is due to the TinkerPop Java client not finding the appropriate serializer. This issue typically arises when the HugeGraphSONModule, which includes serializers for StringId and other HugeGraph-specific types, isn't properly registered with the TinkerPop GraphSONMapper.

To resolve this, you need to ensure that the HugeGraphIoRegistry is being used, as it registers the HugeGraphSONModule. This registration is crucial for the TinkerPop client to handle StringId objects and other custom types defined by HugeGraph. Here's how you can explicitly register the HugeGraphSONModule in your client application:

GraphSONMapper mapper = GraphSONMapper.build()
    .addRegistry(HugeGraphIoRegistry.getInstance())
    .create();

This code snippet configures the GraphSONMapper to include the HugeGraphSONModule, ensuring that the TinkerPop client can serialize or deserialize objects when communicating with HugeGraph, including handling StringId objects.

Make sure to adjust your client setup with this configuration. If the issue persists after this adjustment, further investigation into your client setup might be necessary. For more detailed information, you can refer to the HugeGraphSONModule.java in the HugeGraph repository.

Sources

#### About Dosu This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
kd1510 commented 2 months ago

@dosu-bot Hello, thanks for the message. I have set up the above but I am getting the following error org.apache.tinkerpop.gremlin.driver.ser.SerializationException: org.apache.tinkerpop.shaded.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `org.apache.tinkerpop.gremlin.driver.message.ResponseMessage` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

code:

    val registry = GraphSONMapper.build()
        .addRegistry(HugeGraphIoRegistry.instance())
        .create()

    val serializer = GraphSONMessageSerializerV3d0(registry)

    var cluster = Cluster.build().serializer(serializer).addContactPoint("localhost").port(8182).create()

    val gremCli = cluster.connect<Client>()

    val g = traversal().withRemote(DriverRemoteConnection.using(gremCli, "__g_hugegraph"))