0
votes

I am following the examples on the docs and am stuck at Calling Java Methods. When I run

[:find ?k ?v
 :where [(System/getProperties) [[?k ?v]]]]

I get a FileNotFoundException Could not locate System__init.class or System.clj on classpath. clojure.lang.RT.load (RT.java:463).

When I run (System/getProperties) in the REPL, I get results.

{"java.runtime.name" "OpenJDK Runtime Environment",
 "sun.boot.library.path" "/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64",
 "java.vm.version" "25.181-b13",
 ...}

I tried running the snippet with a fully qualified class name (java.lang.System/getProperties) and I still get the error.

(d/q '[:find ?k ?v
       :where
       [(java.lang.System/getProperties) [[?k ?v]]]
       [(.endsWith ^String ?k "version")]])

Clojure Version: 1.9.0

Datomic Version: [com.datomic/datomic-pro "0.9.5703"] (on-prem)

Any ideas what I need to do to get this working? I am developing and running the REPL using IntelliJ.

1
Maybe try the fully-qualified class name, i.e (java.lang.System/getProperties)? Also, make sure to tell us what version / platform of Datomic you're running. - Valentin Waeselynck
Yeah, I tried that but still FileNotFoundException Could not locate java/lang/System__init.class or java/lang/System.clj on classpath. clojure.lang.RT.load (RT.java:463). Let me get the version details for you. - Clarice Bouwer

1 Answers

0
votes

Stuart Halloway pointed out that he believes that it is a bug introduced with classpath function support. Datomic is incorrectly treating that symbol as a Clojure name.

The workaround is to give it a Clojure symbol to work with. For example:

(defn get-props [] (System/getProperties))

(d/q '[:find ?k ?v
       :where [(user/get-props) [[?k ?v]]]])