Serialization 如何在Corda中编写作为命令参数的java类?

Serialization 如何在Corda中编写作为命令参数的java类?,serialization,corda,Serialization,Corda,我正在探索科达。我从cordapp模板java开始。我正在尝试添加一个flowNewFlow,其中有一个项作为成员变量。项目的定义- @CordaSerializable public class Item { private final String name; private final Party owner; public Item(String name, Party owner) { this.name = name; thi

我正在探索科达。我从
cordapp模板java
开始。我正在尝试添加一个flow
NewFlow
,其中有一个项作为成员变量。项目的定义-

@CordaSerializable
public class Item {
    private final String name;
    private final Party owner;

    public Item(String name, Party owner) {
        this.name = name;
        this.owner = owner;
    }

    public String getName() {
        return name;
    }

    public Party getOwner() {
        return owner;
    }
}
部署节点时,我无法调用此流。这就是我调用
NewFlow
的方式:

start NewFlow price: 100, item: { name: Item1, owner: "O=PartyB,L=New York,C=US" }, timeFrame: "toTimeStr=12-DEC-2019 12:26:45", parties:["O=PartyB,L=New York,C=US"]
它抛出一个错误-

No matching constructor found:
- [java.lang.Integer, com.template.states.Item, com.template.states.TimeFrame, net.corda.core.identity.Party[]]: Could not parse as a command: Cannot construct instance of `com.template.states.Item` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: UNKNOWN; line: -1, column: -1]
对于类
,我还需要做什么?或者这只是一些序列化问题

编辑:

流类中的代码段-

public class NewFlow extends FlowLogic<Void> {

    private final int price;
    private final Item item;
    private final TimeFrame timeframe;
    private final List<Party> parties;

    /**
     * The progress tracker provides checkpoints indicating the progress of the flow to observers.
     */
    private final ProgressTracker progressTracker = new ProgressTracker();

    public PostTenderFlow(Integer price, Item item, TimeFrame timeframe, Party[] parties) {
        this.price = price;
        this.item = item;//new Item(itemName, getOurIdentity());
        this.timeframe = timeframe;
        this.parties= Arrays.asList(parties);
    }
公共类NewFlow扩展了FlowLogic{
私人最终int价格;
私人最终项目;
私人最终时间表;
非公开最终名单缔约方;
/**
*进度跟踪器向观察者提供指示流进度的检查点。
*/
private final ProgressTracker ProgressTracker=新ProgressTracker();
公开投标后流程(整数价格、项目、时间表、第[]方){
这个价格=价格;
this.item=item;//新项(itemName,getOurIdentity());
this.timeframe=时间段;
this.parties=Arrays.asList(parties);
}
您的错误表明“找不到匹配的构造函数”。问题在于您定义的流类。您需要在流类中有一个构造函数,该构造函数接受您从命令行传递的参数

例如,如果NewFlow类具有构造函数:

public NewFlow(int price, String someData){
   ...
}
您可以使用以下命令启动流:

flow start NewFlow price: 100, someData: "My Data"

我确实有一个构造函数在里面。用代码片段更新了问题。我想你们需要在你们的Item类中有一个默认的构造函数。