Daml Script error - NOT_FOUND, PACKAGE_NOT_FOUND

PS C:\loan-project> daml script --dar .daml/dist/loan-project-0.0.2.dar --script-name Test:testLoan --ledger-host localhost --ledger-port 6865

Slf4jLogger started
Exception in thread "main" com.daml.lf.engine.script.Script$FailedCmd: Command submit failed: NOT_FOUND: PACKAGE_NOT_FOUND(11,5248c2e8): Couldn't find package 07fd0b5f3e1241241649249783aa86d7fe8049c0cda946fadd84246e18a43f53 while looking for template or interface 07fd0b5f3e1241241649249783aa86d7fe8049c0cda946fadd84246e18a43f53:Main:LoanRequest
Daml stacktrace:
submit at 07fd0b5f3e1241241649249783aa86d7fe8049c0cda946fadd84246e18a43f53:Test:11
        at com.daml.lf.engine.script.v1.Runner.$anonfun$runWithClients$11(Runner.scala:147)
        at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:475)
        at org.apache.pekko.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:73)Running CoordinatedShutdown with reason [ActorSystemTerminateReason]

        at org.apache.pekko.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:110)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
        at org.apache.pekko.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:110)
        at org.apache.pekko.dispatch.TaskInvocation.run(AbstractDispatcher.scala:59)
        at org.apache.pekko.dispatch.ForkJoinExecutorConfigurator$PekkoForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:57)
        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,5248c2e8): Couldn't find package 07fd0b5f3e1241241649249783aa86d7fe8049c0cda946fadd84246e18a43f53 while looking for template or interface 07fd0b5f3e1241241649249783aa86d7fe8049c0cda946fadd84246e18a43f53:Main:LoanRequest
        at io.grpc.Status.asRuntimeException(Status.java:537)
        at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:538)
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:574)
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:72)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:742)
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:723)
        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:834)
daml-helper: Received ExitFailure 1 when running
Raw command: java "-Dlogback.configurationFile=C:\\Users\\Admin\\AppData\\Roaming\\daml\\sdk\\2.9.4\\daml-sdk/script-logback.xml" -jar "C:\\Users\\Admin\\AppData\\Roaming\\daml\\sdk\\2.9.4\\daml-sdk/daml-sdk.jar" script --dar .daml/dist/loan-project-0.0.2.dar --script-name Test:testLoan --ledger-host localhost --ledger-port 6865

Also, I am finding some issues with Daml.Script package when i am importing that in script
Anyone having any ideas on the same?

Hi, @Rohit_Mittal!

The important part of that error message is:

Couldn’t find package 07fd0b5f3e1241241649249783aa86d7fe8049c0cda946fadd84246e18a43f53

That means that when the script runner tried to run the Test:testLoan script in the ledger, the ledger could not find the package 07fd0b5f3....

Here are some things that might help here:

  1. List the packages that have been uploaded to the ledger:

    daml packages list --host localhost --port 6865
    

    Look through the list of packages. Does it include the package 07fd0b5f3... ?

  2. Notice that the file .daml/dist/loan-project-0.0.2.dar contains the package 07fd0b5f3....

    daml damlc inspect-dar .daml/dist/loan-project-0.0.2.dar
    
  3. Upload the DAR file to the ledger.

    daml ledger upload-dar .daml/dist/loan-project-0.0.2.dar  --host localhost --port 6865
    
  4. Try running your script again.


The above steps are instructive. Additionally, the daml script command includes a convenient --upload-dar option as an alternative to a separate daml ledger upload call.