1

My code:

(ns model.document
  (:gen-class
    :name model.document
    :implements java.io.Serializable
    :state "state"
    :init "init"
    :constructors {[String String String] []}
    :methods [[getContent [] String]
              [getTitle [] String]
              [getUrl [] String]]))

(defn -init [content title url]
  [[] (atom {:content content
             :title title
             :url url})])

(defn- get-field [this k]
  (@(.state this) k))

(defn getContent [this]
  (get-field this :content))

(defn getTitle [this]
  (get-field this :title))

(defn getUrl [this]
  (get-field this :url))

And it's use:

(ns classification-server.classifier
  (:require [model.document :refer :all]))

(new model.document "my-content" "my-title" "my-url")

And I get the unhelpful:

Caused by: java.lang.ClassNotFoundException: model.document, compiling:(classification_server/classifier.clj:13:12)

Please help me SO. You're my only hope...

1 Answer 1

5

The gen-class namespace you posted doesn’t compile, because the :implements specification expects a vector of symbols, not a symbol. If you change that line to

:implements [java.io.Serializable]

you will be able to compile (and instantiate) the class – however, it will not be functional, because there are other issues with your gen-class spec,such as the prefixed functions being absent (-getContent etc.).

I suggest you read the gen-class documentation and simplify the problem further.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.