问题
I try to write a demo - deliverydemo base on bootcamp-cordapp and refer cordapp-example for my own Order Flow. After Party A-C and Notary started by command "build/nodes/runnodes":
- TokenIssueFlow is worked.
- I can saw my Order Flow by "flow list" command in CLI. But got "missing parameter name at index 0 {}" when try to start my order flow.
Thu Jul 26 09:41:51 CST 2018>>> flow start OrderPlaceFlow$OrderPlaceRequestFlow buyer: PartyB, seller: PartyC, sellingPrice: 12.9, downPayments: 0.1 flow start OrderPlaceFlow$OrderPlaceRequestFlow buyer: PartyB, seller: PartyC, sellingPrice: 12.9, downPayments: 0.1: exception: Could not parse as a command: Method lambda$call$6 missing parameter name at index 0 Thu Jul 26 09:41:55 CST 2018>>> E 09:41:55+0800 [pool-8-thread-8] command.CRaSHSession.execute - Error while evaluating request 'flow start OrderPlaceFlow$OrderPlaceRequestFlow buyer: PartyB, seller: PartyC, sellingPrice: 12.9, downPayments: 0.1' flow start OrderPlaceFlow$OrderPlaceRequestFlow buyer: PartyB, seller: PartyC, sellingPrice: 12.9, downPayments: 0.1: exception: Could not parse as a command: Method lambda$call$6 missing parameter name at index 0 {} net.corda.client.jackson.StringToMethodCallParser$UnparseableCallException$ReflectionDataMissing: Could not parse as a command: Method lambda$call$6 missing parameter name at index 0 at net.corda.client.jackson.StringToMethodCallParser.paramNamesFromMethod(StringToMethodCallParser.kt:131) ~[corda-jackson-corda-3.0.jar:?]
Thu Jul 26 09:38:32 CST 2018>>> flow list com.cienet.deliverydemo.order.OrderPlaceFlow$OrderPlaceRequestFlow com.cienet.deliverydemo.token.TokenIssueFlow net.corda.core.flows.ContractUpgradeFlow$Authorise net.corda.core.flows.ContractUpgradeFlow$Deauthorise net.corda.core.flows.ContractUpgradeFlow$Initiate
Thu Jul 26 09:38:34 CST 2018>>>
public OrderPlaceRequestFlow(Party buyer, Party seller, float sellingPrice, float downPayments) {
this.buyer = buyer;
this.seller = seller;
this.sellingPrice = sellingPrice;
this.downPayments = downPayments;
}
回答1:
I still do not know why, but that is working after build clean and re-build by:
./gradlew clean
./gradlew test
./gradlew deployNodesJava -Poffline=true
回答2:
Sometimes, that is a re-build issue. But, if you are using JAVA for a flow, and using session send/receive/unwarp, this error will rise. And not happen in Kotlin code.
EDIT:
I add a Kotlin code just for sending/receiving StateAndRef.
class TokenAsk(private val otherPartyFlow: FlowSession) {
@Suspendable
fun askTokenState(amount: Int, owner: Party): StateAndRef<TokenState> {
otherPartyFlow.send(amount)
otherPartyFlow.send(owner)
return otherPartyFlow.receive<StateAndRef<TokenState>>().unwrap { it }
}
@Suspendable
fun receiveAmount(): Int =
otherPartyFlow.receive<Int>().unwrap{it}
@Suspendable
fun receiveOwner(): Party =
otherPartyFlow.receive<Party>().unwrap{it}
@Suspendable
fun sendStateAndRef(tokenStateAndRef: StateAndRef<TokenState>) =
otherPartyFlow.send(tokenStateAndRef)
}
** EDIT 2 **
I faced this error again, when I am using Kotlin code. I have to remove the "private" key word in the constructor of a Flow for avoiding this error.
From:
class Initiator(private val number: String, private val otherParty: Party) : FlowLogic<SignedTransaction>()
To:
class Initiator(val number: String, val otherParty: Party) : FlowLogic<SignedTransaction>()
来源:https://stackoverflow.com/questions/51529864/missing-parameter-name-at-index-0