Error when executing a script

G-d willing

Hello,
I am executing a script against the Daml Hub. While the command queryContractId works with no problem.
But, when I try to create a contract it fails. Does anyone knows what can it be?

Here is the code I am trying to execute, it is saved in a file named: TestingScript.daml

data InputParams = InputParams
  with 
    scriptCid: ContractId ScriptTestContract
    carrier: Party

template ScriptTestContract 
  with
    user: Party
    value: Int
  where
    signatory user
    

checkTranslationCode : InputParams -> Script ()
checkTranslationCode InputParams{..} = do
  contractCid <- submit carrier do
    createCmd ScriptTestContract with
      user = carrier
      value = 1
  pure ()

I am executing the command from my terminal:

daml script --dar .daml/dist/script-testing-0.0.1.dar --ledger-host ......daml.app --ledger-port 443 --script-name TestingScript:exampleScript --input-file InputArguments.JSON --tls --application-id damlhub --access-token-file access_token_file

And this is the error I am getting:

Exception in thread "main" com.daml.lf.engine.script.ScriptF$FailedCmd: Command submit failed: NOT_FOUND: PACKAGE_NOT_FOUND(11,ee805c33): Couldn't find package b367afe5b05c8e811ceaaa013f805b7a7eb37a09e4426df199d9b82beb4afbca while looking for template b367afe5b05c8e811ceaaa013f805b7a7eb37a09e4426df199d9b82beb4afbca:TestingScript:ScriptTestContract
Daml stacktrace:
submit at b367afe5b05c8e811ceaaa013f805b7a7eb37a09e4426df199d9b82beb4afbca:TestingScript:24
        at com.daml.lf.engine.script.Runner.$anonfun$runWithClients$10(Runner.scala:453)
        at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:475)
        at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:63)
        at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:100)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
        at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:100)
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:49)
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: io.grpc.StatusRuntimeException: NOT_FOUND: PACKAGE_NOT_FOUND(11,ee805c33): Couldn't find package b367afe5b05c8e811ceaaa013f805b7a7eb37a09e4426df199d9b82beb4afbca while looking for template b367afe5b05c8e811ceaaa013f805b7a7eb37a09e4426df199d9b82beb4afbca:TestingScript:ScriptTestContract
        at io.grpc.Status.asRuntimeException(Status.java:535)
        at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:534)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:562)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:743)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:722)
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
daml-helper: Received ExitFailure 1 when running
Raw command: java -Dlogback.configurationFile=/home/avraham/.daml/sdk/2.0.0/daml-sdk/script-logback.xml -jar /home/avraham/.daml/sdk/2.0.0/daml-sdk/daml-sdk.jar script --dar .packages/triggers/.daml/dist/sor-mvp-triggers-0.0.1.dar --ledger-host l9d0c63cgrner1qo.daml.app --ledger-port 443 --script-name TestingScript:checkTranslationCode --input-file InputArguments.json --tls --application-id damlhub --access-token-file access_token_file --output-file policy_details.json

I did find some info on the docs regarding the JSON-API here.
I am not sure that it is possible to execute create and exercise commands only through JSON-API. Is it true?

@cohen.avraham I think there is something wrong with your script. You say that you’re calling

daml script --dar .daml/dist/script-testing-0.0.1.dar --ledger-host ......daml.app --ledger-port 443 --script-name TestingScript:exampleScript --input-file InputArguments.JSON --tls --application-id damlhub --access-token-file access_token_file

But notice this line in the second output

Raw command: java -Dlogback.configurationFile=/home/avraham/.daml/sdk/2.0.0/daml-sdk/script-logback.xml -jar /home/avraham/.daml/sdk/2.0.0/daml-sdk/daml-sdk.jar script --dar .packages/triggers/.daml/dist/sor-mvp-triggers-0.0.1.dar --ledger-host l9d0c63cgrner1qo.daml.app --ledger-port 443 --script-name TestingScript:checkTranslationCode --input-file InputArguments.json --tls --application-id damlhub --access-token-file access_token_file --output-file policy_details.json```

In particular

–dar .packages/triggers/.daml/dist/sor-mvp-triggers-0.0.1.dar

Thanks @Leonid_Rozenberg for your response, however, what’s wrong with the DAR file name?

It is not the dar filename. Rather it looks like you are invoking the command to look for your script in your trigger dar, not the script-testing one.

1 Like

Specifically to your question on the json-api, @cohen.avraham indeed you can execute create-and-exercise commands.

G-d willing

I succeeded in understanding the root cause of this problem, however, I don’t know how to fix it.
The problem is that the templates I defined in the project are not included in the DAR file that is being created.
I am using daml build to build the project, and once it is ready I listed all the objects inside the DAR file, and all the templates I created in one specific file are not listed.
I am checking that using the jar tvf {dar file}
I even searched inside the file using the |grep argument, but the templates are not there.
Does anyone know what can cause this problem?

Can you double-check with

daml damlc inspect $PATH_TO_DAR --json

DAR files are not JAR files, so using the jar tf command is not necessarily giving your useful answers.

@Leonid_Rozenberg, @Gary_Verhaegen. I think I understand the reason for the problem I was having.
In my project I am running a script against the Daml-hub. For that I am uploading my DAR file (let’s call it A).
The script I am running is part of a different DAR file (I will call it B) which dependent on A (using the data-dependencies section of the daml.yaml file.
While I was doing some changes on the script, I “accidentally” did daml build to DAR A. So now, DAR A on the daml-hub has different package id than the one my DAR B is using. So this is why it couldn’t find the templates I was trying to create.

2 Likes