# Error when executing a script

**URL:** <https://forum.canton.network/t/error-when-executing-a-script/4496>\
**Category:** App Development\
**Tags:** daml-script, daml, damlhub\
**Created:** [May 8, 2022, 6:36pm UTC](https://forum.canton.network/t/error-when-executing-a-script/4496 "2022-05-08T18:36:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cohen.avraham](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cohen.avraham](https://forum.canton.network/u/cohen.avraham)\
**Post date:** [May 8, 2022, 6:36pm UTC](https://forum.canton.network/t/error-when-executing-a-script/4496/1 "2022-05-08T18:36:35Z")

</div>

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

```haskell
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:

```haskell
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:

```haskell
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](https://docs.daml.com/daml-script/#running-daml-script-against-the-http-json-api).  
I am not sure that it is possible to execute create and exercise commands only through JSON-API. Is it true?

---

<div class="post-metadata">

**Author:** ![Leonid\_Rozenberg](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/leonid_rozenberg/32/48_2.png) [@Leonid\_Rozenberg](https://forum.canton.network/u/Leonid_Rozenberg)\
**Post date:** [May 9, 2022, 1:16am UTC](https://forum.canton.network/t/error-when-executing-a-script/4496/2 "2022-05-09T01:16:09Z")

</div>

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

```haskell
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

````haskell
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**

---

<div class="post-metadata">

**Author:** ![cohen.avraham](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cohen.avraham](https://forum.canton.network/u/cohen.avraham)\
**Post date:** [May 9, 2022, 1:21am UTC](https://forum.canton.network/t/error-when-executing-a-script/4496/3 "2022-05-09T01:21:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Leonid\_Rozenberg](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/leonid_rozenberg/32/48_2.png) [@Leonid\_Rozenberg](https://forum.canton.network/u/Leonid_Rozenberg)\
**Post date:** [May 9, 2022, 2:36am UTC](https://forum.canton.network/t/error-when-executing-a-script/4496/4 "2022-05-09T02:36:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![chris.norris](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/chris.norris/32/688_2.png) [@chris.norris](https://forum.canton.network/u/chris.norris)\
**Post date:** [May 9, 2022, 9:03am UTC](https://forum.canton.network/t/error-when-executing-a-script/4496/5 "2022-05-09T09:03:17Z")

</div>

Specifically to your question on the json-api, @cohen.avraham indeed you can execute [create-and-exercise commands](https://docs.daml.com/json-api/index.html#create-and-exercise-in-the-same-transaction).

---

<div class="post-metadata">

**Author:** ![cohen.avraham](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cohen.avraham](https://forum.canton.network/u/cohen.avraham)\
**Post date:** [May 9, 2022, 12:18pm UTC](https://forum.canton.network/t/error-when-executing-a-script/4496/6 "2022-05-09T12:18:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [May 9, 2022, 3:53pm UTC](https://forum.canton.network/t/error-when-executing-a-script/4496/7 "2022-05-09T15:53:20Z")

</div>

Can you double-check with

```haskell
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.

---

<div class="post-metadata">

**Author:** ![cohen.avraham](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cohen.avraham](https://forum.canton.network/u/cohen.avraham)\
**Post date:** [May 9, 2022, 8:32pm UTC](https://forum.canton.network/t/error-when-executing-a-script/4496/8 "2022-05-09T20:32:16Z")

</div>

@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.
