3

Getting ClassNotFoundException when i use a class from second order dependency. when i run lein uberjar or install it fails with

java.lang.ClassNotFoundException: incanter.core.Dataset, compiling:(myproject/routes/evaluate.clj:1:1). 

However, it gets compiled.

Exception in thread "main" java.lang.ClassNotFoundException: incanter.core.Dataset, compiling:(myproject/routes/evaluate.clj:1:1)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:6730)
        at clojure.lang.Compiler.analyze(Compiler.java:6524)
        at clojure.lang.Compiler.analyze(Compiler.java:6485)
        at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5861)
        at clojure.lang.Compiler$TryExpr$Parser.parse(Compiler.java:2261)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:6723)
        at clojure.lang.Compiler.analyze(Compiler.java:6524)

My project.clj file (selected part)

(defproject myproject"0.2.2-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.7.0"]
               [grafter "0.7.0"]]
)

The incanter.core.Dataset is used by grafter:0.7.0.

My clojure file where i use it is myproject/routes/evaluate.clj

(ns myproject.routes.evaluate
(:gen-class
    :name myproject.routes.evaluate
    :prefix "service-"
    :methods [^:static [executePipeline [java.lang.String java.lang.String java.lang.String] incanter.core.Dataset]]))

(defn service-executePipeline [data command pipeline]   
  (execute-pipeline data command pipeline))

I have went through few posts relate to gen-class and aot solutions. Nothing was useful. I am quiet new to Clojure. I am not completely sure what's happening. Can i solve this issue? What am i doing wrong?

jmargolisvt
  • 5,722
  • 4
  • 29
  • 46
NehaM
  • 1,272
  • 1
  • 18
  • 32
  • 2
    Since you said you are new to Clojure; are you sure you need a `gen-class` here? Is your going to be used by some Java (or other JVM lang) code? Also if your code makes direct use of a class/ns/function you should add it as a dependency. `it gets compiled` means less in Clojure than in statically compiled languages. You should also `(:import ...)` that class. – muhuk Mar 07 '16 at 16:45
  • Hi, Yes. I need it to be used by another Java Module. I tried `:import `for that class. Getting same exception as mentioned above. Both myproject and grafter:0.7.0 have`:profiles {:uberjar {:aot :all}}`. But i don't see aforementioned class in that jar. As i don't have control over that second order dependency, is there anyway to generate this class from my side? or any other solutions? – NehaM Mar 08 '16 at 09:51
  • @muhuk I have tried having it as direct dependency too. It doesn't help. Also makes sense as nothing much changed from dependency perspective. – NehaM Mar 08 '16 at 11:03

0 Answers0