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;
}
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
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>()
Related
I am trying to create and use a simple dictionary using TFPGmap:
program rnTFPGmap;
{$mode objfpc}
uses fgl;
var
mydict: specialize TFPGmap<string, string>;
key: string;
i: longint;
begin
mydict.create;
mydict.add('k1','v1');
mydict.add('k2','v2');
mydict.add('k3','v3');
//for key in mydict.keys do {does not work either;}
for i := 1 to length(mydict) do {line 17: first error from here. }
writeln(mydict[i]);
end.
However, it is giving following error:
$ fpc soq_rntfpgmap
Free Pascal Compiler version 3.0.0+dfsg-11+deb9u1 [2017/06/10] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling soq_rntfpgmap.pas
soq_rntfpgmap.pas(17,16) Error: Type mismatch
soq_rntfpgmap.pas(18,19) Error: Incompatible type for arg no. 1: Got "LongInt", expected "ShortString"
soq_rntfpgmap.pas(22) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode
Edit: I tried to modify the code according to documentation and came up with following version:
program rnTFPGmap;
{$mode objfpc}
uses fgl;
type
tuple = specialize TFPGmap<string, string>;
mydict = Array of tuple;
var
dict: mydict;
i: tuple;
item: string;
begin
setlength(dict, length(dict)+3);
dict.add('k1','v1'); {error on this line: "CREATE" expected but "ADD" found}
dict.add('k2','v2');
dict.add('k3','v3');
writeln('dict.count: ', dict.count);
for i in dict do
writeln(i);
end.
But I am now getting following error:
$ fpc soq_rntfpgmap
Free Pascal Compiler version 3.0.0+dfsg-11+deb9u1 [2017/06/10] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling soq_rntfpgmap.pas
soq_rntfpgmap.pas(13,25) Warning: Variable "dict" of a managed type does not seem to be initialized
soq_rntfpgmap.pas(14,7) Fatal: Syntax error, "CREATE" expected but "ADD" found
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode
Not able to sort this out.
Following code works. See comments for some explanations:
program rnTFPGmap;
{$mode objfpc}
uses fgl;
type
Rndict = specialize TFPGmap<string, string>;{define type under type}
var
dict: Rndict; {define object under var}
i: integer;
{main: }
begin
dict := Rndict.Create; {create object in main}
dict.add('k1','v1');
dict.add('k2','v2');
dict.add('k3','v3');
for i := 0 to (dict.count-1) do begin
writeln('i: ',i, '; key: ', dict.getkey(i), '; value: ', dict.getdata(i));
end;
end.
Output:
i: 0; key: k1; value: v1
i: 1; key: k2; value: v2
i: 2; key: k3; value: v3
I thank #DavidHeffernan for his guidance.
Currently:
Sbt has multiple test runners: scalaTest, junit-interface, etc..
Each test runner has it's own set of flags (scalaTest flags, junit-interface flags).
You can pass flags through sbt to the test runners, for example:
$ sbt '<project>/test-only * -- -f <out_file>' (-f is a scalaTest flag)
However, the flags seem to be passed to all test runners, even if a flag is not compatible with all test runners.
I'm also experiencing behavior contrary to what I found in the documentation. ScalaTest says the -v flag will "print the ScalaTest version" and junit-interface says it will "Log "test run started" / "test started" / "test run finished" events on log level "info" instead of "debug"." Instead ScalaTest throws an unrecognised flag exception.
$ sbt '<project>/test-only * -- -v'
java.lang.IllegalArgumentException: Argument unrecognized by ScalaTest's Runner: -v
at org.scalatest.tools.ArgsParser$.parseArgs(ArgsParser.scala:425)
at org.scalatest.tools.Framework.runner(Framework.scala:929)
...
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[error] (elasticSearchDriver/test:testOnly) java.lang.IllegalArgumentException: Argument unrecognized by ScalaTest's Runner: -v
[error] Total time: 1 s, completed Aug 15, 2017 11:12:56 AM
Question:
What is the actual underlying behavior of the flags passed to the test runners through sbt? Is there a bit of documentation that explains what's going on?
By looking at SBT (0.13.x) we eventually get to a part where:
def inputTests(key: InputKey[_]): Initialize[InputTask[Unit]] = inputTests0.mapReferenced(Def.mapScope(_ in key.key))
private[this] lazy val inputTests0: Initialize[InputTask[Unit]] =
{
val parser = loadForParser(definedTestNames)((s, i) => testOnlyParser(s, i getOrElse Nil))
Def.inputTaskDyn {
val (selected, frameworkOptions) = parser.parsed
val s = streams.value
val filter = testFilter.value
val config = testExecution.value
implicit val display = Project.showContextKey(state.value)
val modifiedOpts = Tests.Filters(filter(selected)) +: Tests.Argument(frameworkOptions: _*) +: config.options
val newConfig = config.copy(options = modifiedOpts)
val output = allTestGroupsTask(s, loadedTestFrameworks.value, testLoader.value, testGrouping.value, newConfig, fullClasspath.value, javaHome.value, testForkedParallel.value, javaOptions.value)
val taskName = display(resolvedScoped.value)
val trl = testResultLogger.value
val processed = output.map(out => trl.run(s.log, out, taskName))
Def.value(processed)
}
}
Notice this line: Tests.Filters(filter(selected)) +: Tests.Argument(frameworkOptions: _*) +: config.options
By reading this I deduce that sbt passes the arguments you pass to it to all the underlying testing frameworks.
Solution
Don't pass test framework flags in your commands. Configure them in your *.sbt files like:
testOptions in Test += Tests.Argument(TestFrameworks.ScalaCheck, "-f")
Documentation on test framework arguments
With the following sample SBT build file, I can pass arguments to my InputTask from within the SBT Interactive Mode but not from without. Is there a way?
Sample build.sbt:
import complete.DefaultParsers._
lazy val sampleDoSomething = inputKey[Unit]("Will print arguments.")
lazy val commonSettings = Seq(
organization := "com.example",
version := "0.1.0-SNAPSHOT"
)
lazy val taskInputTaskProject = (project in file(".")).
settings(commonSettings: _*).
settings(
sampleDoSomething := {
println("Arguments: ")
val args = spaceDelimited("<arg>").parsed
args foreach println
}
)
Successfully invoking task from within SBT Interactive mode:
$ sbt
[info] Set current project to taskInputTaskProject (in build file:/study/sbt/input-tasks/)
> sampleDoSomething a b c
Arguments:
a
b
c
[success] Total time: 0 s, completed Mar 22, 2016 1:06:58 PM
Successfully Invoking task from command line without arguments:
$ sbt sampleDoSomething
[info] Set current project to taskInputTaskProject (in build file:/study/sbt/input-tasks/)
Arguments:
[success] Total time: 0 s, completed Mar 22, 2016 1:06:18 PM
Failure to invoke task from command line with arguments:
$ sbt sampleDoSomething a b c
[info] Set current project to taskInputTaskProject (in build file:/study/sbt/input-tasks/)
Arguments:
[success] Total time: 0 s, completed Mar 22, 2016 1:06:44 PM
[error] Not a valid command: a
[error] Expected 'all'
[error] Not a valid project ID: a
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: a
[error] a
[error] ^
sbt "sampleDoSomething a b c"
See doc: http://www.scala-sbt.org/0.13/docs/Running.html#Batch+mode
Cheers
I am trying to query a table called "user_path_summary" for a value that is equal to my hashkey, "username" and also equal to my global secondary index hashkey, "full_path". I am hoping to get back one attribute, "articles_read". The parameters that I am using are:
var params = {
"TableName": "user_path_summary",
"IndexName": "full_path_index",
"KeyConditionExpression": "full_path = :v_full_path AND username = v:username",
"ExpressionAttributeValues": {
":v_username": {"S" : username},
":v_full_path": {"S": full_path}
},
"ProjectionExpression": "articles_read",
"ScanIndexForward": false
};
I get the following error.
{ [MultipleValidationErrors: There were 2 validation errors:
* MissingRequiredParameter: Missing required key 'KeyConditions' in params
* UnexpectedParameter: Unexpected key 'KeyConditionExpression' found in params]
message: 'There were 2 validation errors:\n* MissingRequiredParameter: Missing required key \'KeyConditions\' in params\n* UnexpectedParameter: Unexpected key \'KeyConditionExpression\' found in params',
code: 'MultipleValidationErrors',
errors:
[ { [MissingRequiredParameter: Missing required key 'KeyConditions' in params]
message: 'Missing required key \'KeyConditions\' in params',
code: 'MissingRequiredParameter',
time: Sat Aug 01 2015 14:54:52 GMT-0400 (EDT) },
{ [UnexpectedParameter: Unexpected key 'KeyConditionExpression' found in params]
message: 'Unexpected key \'KeyConditionExpression\' found in params',
code: 'UnexpectedParameter',
time: Sat Aug 01 2015 14:54:52 GMT-0400 (EDT) } ],
time: Sat Aug 01 2015 14:54:52 GMT-0400 (EDT) }
I am confused because the error pertains to the missing parameter "KeyConditions", which is identified as a legacy parameter in the query API Reference, and also to the unexpected parameter "KeyConditionExpression" which the api reference says to use instead of "KeyConditions".
Is there a setting somewhere that I am missing? Is my syntax messed up somewhere. Please let me know, I am clearly missing something.
I have a SBT multi project which includes two sub projects. One is an ordinary Scala web server project and the other is just some web files. With my self written SBT plugin I can run Gulp on the web project. This Gulp task runs asynchronous. So with
sbt "web/webAppStart" "server/run"
I can start the Gulp development web server and my Scala backend server in parallel. Now I want to create a new task, that combines them both. So afterwards
sbt dev
for example should do the same. Here is what I tried so far:
// Build.sbt (only the relevant stuff)
object Build extends sbt.Build {
lazy val runServer: InputKey[Unit] = run in server in Compile
lazy val runWeb: TaskKey[Unit] = de.choffmeister.sbt.WebAppPlugin.webAppStart
lazy val dev = InputKey[Unit]("dev", "Starts a development web server")
// Scala backend project
lazy val server = (project in file("project-server"))
// Web frontend project
lazy val web = (project in file("project-web"))
// Root project
lazy val root = (project in file("."))
.settings(dev <<= (runServer) map { (_) => {
// do nothing
})
.aggregate(server, web)
This works so far. Now I don't have any idea, how to make dev also depend on the runWeb task. If I just add the runWeb task like
.settings(dev <<= (runWeb, runServer) map { (_, _) => {
// do nothing
})
then I get the error
[error] /Users/choffmeister/Development/shop/project/Build.scala:59:value map is not a member of (sbt.TaskKey[Unit], sbt.InputKey[Unit])
[error] .settings(dev <<= (runWeb, runServer) map { (_, _) =>
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
Can anyone help me with this please?
The optimal solution would pass the arguments given to dev to the runServer task. But I could also live with making dev a TaskKey[Unit] and then hard code to run runServer with no arguments.
tl;dr Use .value macro to execute dependent tasks or just alias the task sequence.
Using .value macro
Your case seems overly complicated to my eyes because of the pre-0.13 syntax (<<=) and the use of project/Build.scala (that often confuse not help people new to sbt).
You should just execute the two tasks in another as follows:
dev := {
runWeb.value
runServer.value
}
The complete example:
lazy val server = project
lazy val runServer = taskKey[Unit]("runServer")
runServer := {
println("runServer")
(run in server in Compile).value
}
lazy val runWeb = taskKey[Unit]("runWeb")
runWeb := {
println("runWeb")
}
lazy val dev = taskKey[Unit]("dev")
dev := {
println("dev")
}
dev <<= dev dependsOn (runServer, runWeb)
Using alias command
sbt offers alias command that...
[sbt-learning-space]> help alias
alias
Prints a list of defined aliases.
alias name
Prints the alias defined for `name`.
alias name=value
Sets the alias `name` to `value`, replacing any existing alias with that name.
Whenever `name` is entered, the corresponding `value` is run.
If any argument is provided to `name`, it is appended as argument to `value`.
alias name=
Removes the alias for `name`.
Just define what tasks/command you want to execute in an alias as follows:
addCommandAlias("devAlias", ";runServer;runWeb")
Use devAlias as if it were a built-in task:
[sbt-learning-space]> devAlias
runServer
[success] Total time: 0 s, completed Jan 25, 2015 6:30:15 PM
runWeb
[success] Total time: 0 s, completed Jan 25, 2015 6:30:15 PM