Corda服务<init>无法加载org.apache.kafka.common.serialization.StringSerializer

时间:2019-08-30 07:50:40

标签: corda

我实现了一个CordaService,它使用kafka-client库连接到外部apache kafka MQ(内部init块)。 Kafka客户端生产者需要访问jobStart对象,该对象在kafka-client库中定义。

我在cordapp模块的build.gradle中包含了kafka-client库,其中服务定义如下: org.apache.kafka.common.serialization.StringSerializer

在Corda节点启动时,我收到以下消息:

compile "org.apache.kafka:kafka-clients:2.0.1"

corda节点无法加载[WARN ] 2019-08-30T07:04:40,551Z [main] internal.Node.installCordaService - com.example.flow.ProducerService is using legacy CordaService constructor with ServiceHub parameter. Upgrade to an AppServiceHub parameter to enable updated API features. [ERROR] 2019-08-30T07:04:40,716Z [main] internal.Node.installCordaServices - Unable to install Corda service com.example.flow.ProducerService [errorCode=1aep02i, moreInformationAt=https://errors.corda.net/OS/4.0/1aep02i] java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_181] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_181] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_181] at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_181] at net.corda.node.internal.AbstractNode.installCordaService(AbstractNode.kt:654) ~[corda-node-4.0.jar:?] at net.corda.node.internal.AbstractNode.installCordaServices(AbstractNode.kt:577) ~[corda-node-4.0.jar:?] at net.corda.node.internal.AbstractNode.access$installCordaServices(AbstractNode.kt:120) ~[corda-node-4.0.jar:?] at net.corda.node.internal.AbstractNode$start$7.invoke(AbstractNode.kt:382) ~[corda-node-4.0.jar:?] at net.corda.node.internal.AbstractNode$start$7.invoke(AbstractNode.kt:120) ~[corda-node-4.0.jar:?] at net.corda.nodeapi.internal.persistence.CordaPersistence.inTopLevelTransaction(CordaPersistence.kt:236) ~[corda-node-api-4.0.jar:?] at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:221) ~[corda-node-api-4.0.jar:?] at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:199) ~[corda-node-api-4.0.jar:?] at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:205) ~[corda-node-api-4.0.jar:?] at net.corda.node.internal.AbstractNode.start(AbstractNode.kt:371) ~[corda-node-4.0.jar:?] at net.corda.node.internal.Node.start(Node.kt:419) ~[corda-node-4.0.jar:?] at net.corda.node.internal.NodeStartup.startNode(NodeStartup.kt:185) ~[corda-node-4.0.jar:?] at net.corda.node.internal.NodeStartupCli$runProgram$2.run(NodeStartup.kt:110) ~[corda-node-4.0.jar:?] at net.corda.node.internal.NodeStartup$initialiseAndRun$5.invoke(NodeStartup.kt:162) ~[corda-node-4.0.jar:?] at net.corda.node.internal.NodeStartup$initialiseAndRun$5.invoke(NodeStartup.kt:117) ~[corda-node-4.0.jar:?] at net.corda.node.internal.NodeStartupLogging$DefaultImpls.attempt(NodeStartup.kt:450) ~[corda-node-4.0.jar:?] at net.corda.node.internal.NodeStartup.attempt(NodeStartup.kt:117) ~[corda-node-4.0.jar:?] at net.corda.node.internal.NodeStartup.initialiseAndRun(NodeStartup.kt:160) ~[corda-node-4.0.jar:?] at net.corda.node.internal.NodeStartupCli.runProgram(NodeStartup.kt:108) ~[corda-node-4.0.jar:?] at net.corda.cliutils.CordaCliWrapper.call(CordaCliWrapper.kt:184) ~[corda-tools-cliutils-4.0.jar:?] at net.corda.cliutils.CordaCliWrapper.call(CordaCliWrapper.kt:152) ~[corda-tools-cliutils-4.0.jar:?] at picocli.CommandLine.execute(CommandLine.java:1056) ~[picocli-3.8.0.jar:3.8.0] at picocli.CommandLine.access$900(CommandLine.java:142) ~[picocli-3.8.0.jar:3.8.0] at picocli.CommandLine$RunLast.handle(CommandLine.java:1246) ~[picocli-3.8.0.jar:3.8.0] at picocli.CommandLine$RunLast.handle(CommandLine.java:1214) ~[picocli-3.8.0.jar:3.8.0] at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:1122) ~[picocli-3.8.0.jar:3.8.0] at picocli.CommandLine.parseWithHandlers(CommandLine.java:1405) ~[picocli-3.8.0.jar:3.8.0] at net.corda.cliutils.CordaCliWrapperKt.start(CordaCliWrapper.kt:72) ~[corda-tools-cliutils-4.0.jar:?] at net.corda.node.Corda.main(Corda.kt:13) ~[corda-node-4.0.jar:?] Caused by: org.apache.kafka.common.config.ConfigException: Invalid value org.apache.kafka.common.serialization.StringSerializer for configuration key.serializer: Class org.apache.kafka.common.serialization.StringSerializer could not be found. at org.apache.kafka.common.config.ConfigDef.parseType(ConfigDef.java:724) ~[?:?] at org.apache.kafka.common.config.ConfigDef.parseValue(ConfigDef.java:469) ~[?:?] at org.apache.kafka.common.config.ConfigDef.parse(ConfigDef.java:462) ~[?:?] at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:62) ~[?:?] at org.apache.kafka.common.config.AbstractConfig.<init>(AbstractConfig.java:75) ~[?:?] at org.apache.kafka.clients.producer.ProducerConfig.<init>(ProducerConfig.java:364) ~[?:?] at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:304) ~[?:?] at com.example.flow.Producer.<init>(Service.kt:26) ~[?:?] at com.example.flow.Ping.<init>(Service.kt:49) ~[?:?] at com.example.flow.ProducerService.<init>(Service.kt:21) ~[?:?] ... 33 more [INFO ] 2019-08-30T07:04:41,863Z [main] statemachine.SingleThreadedStateMachineManager.invoke - Node ready, info: NodeInfo(addresses=[localhost:10004], legalIdentitiesAndCerts=[O=PartyA, L=London, C=GB], platformVersion=4, serial=1567146729127) [INFO ] 2019-08-30T07:04:42,001Z [Node thread-1] internal.Node.registerJmxReporter - Registering JMX reporter: [INFO ] 2019-08-30T07:04:42,003Z [main] BasicInfo.printBasicNodeInfo - Loaded 2 CorDapp(s) : Contract CorDapp: CorDapp Example version 1 by vendor Corda Open Source with licence Apache License, Version 2.0, Workflow CorDapp: CorDapp Example version 1 by vendor Corda Open Source with licence Apache License, Version 2.0 [INFO ] 2019-08-30T07:04:42,004Z [Node thread-1] internal.Node.registerJolokiaReporter - Registering Jolokia JMX reporter: [INFO ] 2019-08-30T07:04:42,009Z [main] BasicInfo.printBasicNodeInfo - Node for "PartyA" started up and registered in 51.24 sec [INFO ] 2019-08-30T07:04:42,012Z [main] rpc.RPCServer.start - Starting RPC server with configuration RPCServerConfiguration(rpcThreadPoolSize=4, reapInterval=PT1S, deduplicationCacheExpiry=PT24H) 类的原因可能是什么?

1 个答案:

答案 0 :(得分:0)

已解决。必须添加`Thread.currentThread()。setContextClassLoader(null);因为StringSerializer类默认是由应用程序类加载器加载的