cmal
cmal

Reputation: 2222

Clojure java.lang.NoClassDefFoundError when calling clj-time/last-day-of-the-month

I called

(clj-time.core/last-day-of-the-month 1999 2)

and

(clj-time.core/number-of-days-in-the-month 1999 2)

both throws

java.lang.NoClassDefFoundError org/joda/time/DateTime$Property  org.joda.time.DateTime.dayOfMonth (DateTime.java:1971)

The docs says:

(defn last-day-of-the-month
  ([^long year ^long month]
        (last-day-of-the-month- (date-time year month)))
  ([dt]
        (last-day-of-the-month- dt)))

(defn number-of-days-in-the-month
  (^long [^DateTime dt]
         (day (last-day-of-the-month- dt)))
  (^long [^long year ^long month]
         (day (last-day-of-the-month- (date-time year month)))))

What's the wrong I make?

Thanks!

The following is my project settings and dependencies:


(defproject xxx "0.1.2-SNAPSHOT"
:description ""
:dependencies [[org.clojure/clojure "1.8.0"]

...
             [clj-time "0.11.0"]          

...)

and I tried this in project repl:

clj-time=> clj-time.core/last-day-of-the-month
#object[clj_time.core$last_day_of_the_month 0x6a86b560 "clj_time.core$last_day_of_the_month@6a86b560"]

The above results are getting from the repl server to which I connect through channeling by ssh.

When I run lein repl in the local project folder, I can get the right result:

xxx.core=> (clj-time.core/last-day-of-the-month 2016 2)
#object[org.joda.time.DateTime 0x22a0534e "2016-02-29T00:00:00.000Z"]
xxx.core=> (clj-time.core/number-of-days-in-the-month 2016 2)
29

I am new to Clojure. Is this information useful?


After restarting the repl, the problem is solved now.

Upvotes: 0

Views: 343

Answers (1)

Alan Thompson
Alan Thompson

Reputation: 29958

Works great for me.

project.clj:

(defproject clj "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
    [org.clojure/clojure "1.9.0-alpha13"]
    [clj-time "0.12.0"]
  ]
  :java-source-paths ["/home/alan/xpr/src"]
  :main ^:skip-aot clj.core
  :target-path "target/%s"
  :profiles {:dev      {:dependencies [[org.clojure/test.check "0.9.0"]] }
             :uberjar  {:aot :all}}
)

main program:

(ns clj.core
  (:require 
    [clj-time.core :as tm] 
  ))

(println :day  (tm/last-day-of-the-month 1999 2))

(println :days (tm/number-of-days-in-the-month 1999 2))

(defn -main [& args])

Result:

~/clj > lein run    
:day #object[org.joda.time.DateTime 0x61884cb1 1999-02-28T00:00:00.000Z]
:days 28

Upvotes: 1

Related Questions