【问题标题】:Corda Class org.hibernate.exception.SQLGrammarException is not annotated or on the whitelist, so cannot be used in serializationCorda Class org.hibernate.exception.SQLGrammarException 没有注解或者在白名单上,所以不能在序列化中使用
【发布时间】:2018-09-28 19:45:47
【问题描述】:

当我尝试为我的自定义状态查询保险库时出现以下错误。 我的网络中有 3 个节点(节点 1 连接到 sql server 数据库,其他节点连接到 h2 数据库)。查询保管库时在节点 1 上引发以下错误。 (rpcOps.vaultQueryBy().states)

javax.servlet.ServletException: javax.servlet.ServletException: com.esotericsoftware.kryo.KryoException:类 org.hibernate.exception.SQLGrammarException 没有注释或在 白名单,因此不能用于序列化序列化跟踪: 异常(net.corda.core.utilities.Try$Failure) 在 org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.Server.handle(Server.java:561) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:334) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279) [jetty-io-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:104) [jetty-io-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124) [jetty-io-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247) [jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140) [jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:243) [jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679) [jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597) [jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914] 在 java.lang.Thread.run(Thread.java:748) [?:1.8.0_181] 引起:javax.servlet.ServletException: com.esotericsoftware.kryo.KryoException:类 org.hibernate.exception.SQLGrammarException 没有注释或在 白名单,因此不能用于序列化序列化跟踪: 异常(net.corda.core.utilities.Try$Failure) 在 org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489) ~[jersey-container-servlet-core-2.25.jar:?] 在 org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) ~[jersey-container-servlet-core-2.25.jar:?] 在 org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) ~[jersey-container-servlet-core-2.25.jar:?] 在 org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) ~[jersey-container-servlet-core-2.25.jar:?] 在 org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) ~[jersey-container-servlet-core-2.25.jar:?] 在 org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) ~[jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] 在 org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) ~[jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914] ... 14 更多

【问题讨论】:

  • 所以在这种情况下,当我在序列化白名单中添加 SQLGrammarException 类时,我现在得到 SQLServerException 的进一步错误。 sqlException (org.hibernate.exception.SQLGrammarException) 我是否应该将编写查询库的代码的类添加到我的序列化白名单中?
  • 将异常列入白名单后,您将看到“真实”的堆栈跟踪(除非需要将另一个异常列入白名单)。一旦你有了“真实”的堆栈跟踪,我们就可以诊断错误(在一个单独的 SO 问题中)。
  • 谢谢,我会试试看,如果有问题会回复

标签: corda


【解决方案1】:

Corda 限制了可以通过 RPC 在节点和客户端之间发送的类型集。

在您的情况下,您的流程正在抛出SQLGrammarException。节点试图通过 RPC 将此对象传递回客户端,但由于它不是可以通过 RPC 传递的类型之一,因此会引发 KryoException

您需要将SQLGrammarException 添加到节点的序列化白名单中,使用此处描述的过程:https://docs.corda.net/serialization.html#whitelisting。完成此操作后,SQLGrammarException 将正确返回,您可以对其进行检查。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    • 2014-12-30
    • 2013-08-14
    • 2012-01-10
    • 1970-01-01
    • 2011-09-30
    相关资源
    最近更新 更多