Cannot run example RPC client from terminal on Mac


(Gavan) #1

I am going through the cordapp template tutorial.

When trying to run ./gradlew runExampleClientRPC from the terminal I get the following error:

Exception in thread “main” com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID: 70

However it runs fine if I run it through intelliJ.

Any idea why this would happen?


(Joel Dudley) #2

Hi Gavan,

Are you on the release-M7 branch or the master branch?

What part of the build is happening when the exception is thrown?


(Gavan) #3

Yes I am using the release-M7 branch.

Full Error Message:

:java:compileKotlin UP-TO-DATE
:java:compileJava UP-TO-DATE
:java:copyMainKotlinClasses UP-TO-DATE
:java:processResources UP-TO-DATE
:java:classes UP-TO-DATE
:java:runExampleClientRPC
objc[16205]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
I 14:52:44 1 CordaRPCClient.logElapsedTime - Startup took 2550 msec
I 14:52:45 1 CordaRPCClient.logElapsedTime - Proxy build took 847 msec
Exception in thread “main” com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID: 70
Serialization trace:
data (net.corda.core.contracts.TransactionState)
purchaseOrder (com.example.contract.PurchaseOrderState)
data (net.corda.core.contracts.TransactionState)
at com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:137)
at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:693)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:118)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:540)
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:734)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:540)
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:734)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:540)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:816)
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134)
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:816)
at net.corda.core.serialization.WireTransactionSerializer.read(Kryo.kt:302)
at net.corda.core.serialization.WireTransactionSerializer.read(Kryo.kt:266)
at net.corda.core.serialization.NoReferencesSerializer.read(Kryo.kt:470)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813)
at net.corda.core.serialization.KryoKt.deserialize(Kryo.kt:84)
at net.corda.core.transactions.WireTransaction$Companion.deserialize(WireTransaction.kt:56)
at net.corda.core.transactions.WireTransaction$Companion.deserialize$default(WireTransaction.kt:55)
at net.corda.core.transactions.SignedTransaction$tx$2.invoke(SignedTransaction.kt:35)
at net.corda.core.transactions.SignedTransaction$tx$2.invoke(SignedTransaction.kt:23)
at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:131)
at net.corda.core.transactions.SignedTransaction.getTx(SignedTransaction.kt)
at com.example.client.ExampleClientRPC.lambda$main$1(ExampleClientRPC.java:45)
at rx.observables.BlockingObservable$9.onNext(BlockingObservable.java:669)
at rx.internal.operators.NotificationLite.accept(NotificationLite.java:135)
at rx.observables.BlockingObservable.subscribe(BlockingObservable.java:534)
at rx.observables.BlockingObservable.subscribe(BlockingObservable.java:666)
at rx.observables.BlockingObservable.subscribe(BlockingObservable.java:638)
at com.example.client.ExampleClientRPC.main(ExampleClientRPC.java:43)
:java:runExampleClientRPC FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:java:runExampleClientRPC’.

Process ‘command ‘/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java’’ finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 15.381 secs


(Joel Dudley) #4

I’ve encountered this issue before - basically, the logging file is not created in the right place because of a change in the structure of the directory.

Have you moved the source code down or up a level? By this, I mean that by default we have kotlin/source/main and java/source/main. Is there more/less nesting in your case?


(Gavan) #5

ahh I see. Thanks!

I think my structure is the same. I haven’t changed anything to my knowledge and I have both kotlin/source/main and java/source/main.

But anyway it’s not too much of a problem for me since I can run it through intelliJ.


(Joel Dudley) #6

Great. If you do want to diagnose this further, check whether a log4j2.xml file is generated in the kotlin/build/resources/main and java/build/resources/main folders after calling deployNodes from the command line. When I encountered this issue, the absence of those files was a symptom of the logging being set up incorrectly.


(Andrew Ho) #7

Hi Joel,

I’m running into the same problem as Gavan and I’m also on the release-M7 branch (and also on a mac). I checked and the log4j2.xml files do get generated in the java and kotlin folders after calling deployNodes.
the RPC works in IntelliJ for me as well.

Are there any other ideas on why this might be happening?


(Joel Dudley) #8

Hi Andrew,

In my case, it was because I’d changed the layout of my cordapp directory. If you check the build.gradle files, you’ll see the following section:

sourceSets { main { resources { srcDir "../config/dev" } } test { resources { srcDir "../config/test" } } }

This should be updated so that log4j2 can place the logging files in the correct place.