0
votes

I get the following error net.corda.core.CordaRuntimeException: java.io.NotSerializableException: com.example.state.TradeState was not found by the node, check the Node containing the CorDapp that implements com.example.state.TradeState is loaded and on the Classpath.

i am running cordapp as a systemd service. here is the image of the error and my node directory structure

enter image description here

enter image description here

1
my cordapp jar is in the cordapps folderviraj
looks like it cant find my cordapp jar but i have it in the corapps folder a smentioned in docsviraj
looks like the cordapp jar that contains the state is not being included. Sounds like you have the cordapp jar that makes use of the state but not the jar that actually contains the state.Dan Newton
Hey Dan the code jar is there in the cordapp folder it has all classes and packagesviraj

1 Answers

0
votes

This might be an issue cause by multiple constructors. When you overriding Constructors in Corda (Java version), you would need put @ConstructorForDeserialization on the constructor that has the more parameters. Also, you need manually create all the getters as well(for database hibernate).

Here is an example: https://github.com/corda/samples-java/blob/master/Accounts/tictacthor/contracts/src/main/java/com/tictacthor/states/BoardState.java

@ConstructorForDeserialization
public BoardState(UniqueIdentifier playerO, UniqueIdentifier playerX,
                  AnonymousParty me, AnonymousParty competitor,
                  boolean isPlayerXTurn, UniqueIdentifier linearId,
                  char[][] board, Status status) {
    this.playerO = playerO;
    this.playerX = playerX;
    this.me = me;
    this.competitor = competitor;
    this.isPlayerXTurn = isPlayerXTurn;
    this.linearId = linearId;
    this.board = board;
    this.status = status;
}