Reputation: 41
I am getting a FileNotFoundException when using a database function that requires a namespace. I only get the error when using the persistent datomic free database but not when I'm using the memory database.
(ns test.core
(:use [datomic.api :only [q db] :as d]))
(def uris ["datomic:mem://test"
"datomic:free://localhost:4334/test"])
(map
d/delete-database uris)
(map
d/create-database uris)
(def conns (map d/connect uris))
(defn test-entity []
[{:db/id #db/id[:db.part/db]
:test/test "hello"}])
(def db-function
#db/fn {:lang :clojure
:params [database]
:requires [[test.core :as c]]
:code (c/test-entity)})
(map
#(d/transact % [{:db/id #db/id[:db.part/user]
:db/ident :db-function
:db/fn db-function}])
conns)
(map
#(d/transact % [{:db/id #db/id[:db.part/db]
:db/ident :test/test
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}])
conns)
(comment
(db-function nil)
(d/transact (first conns) [[:db-function]])
(d/transact (second conns) [[:db-function]]))
When you evaluate the first and second line in the comment, it's fine but when you evaluate the third line you get an exception.
Do I need to configure something in datomic so that it can "see" my project?
Upvotes: 1
Views: 132
Reputation: 107
When you use an in memory database, the transactor runs in the same JVM instance as the peer, hence with the same classpath. But with the free database, the transactor is running in its own JVM instance, and is not aware about namespaces in the peers.
You can add jars to the transactor classpath by putting them in the lib/ folder.
Upvotes: 2