2
votes

In my clojure project I have a dependency on the javax.jms.MessageListener library. I have this class file in my project in the following directory

My-project
|java-
|    |src -
|    |    |myJavaFile.java
|    |    |jars -
|    |       |library1.jar
|    |       |library2.jar
|    |       |libarary3.jar
|    |javax -
|    |      |jms -
|    |          |MessageListener.class
|project.clj
|src -
|    |my-program1.clj
|    |my-program2.clj
|    |my-program3.clj

Then in my project.clj file I have my java-source-paths set to

:java-source-paths ["java/src" "java/src/jars/" "java/javax/jms"]

but when I go to run my project via lein repl, I get compilation errors saying

java.lang.NoClassDefFoundError: javax/jms/MessageListener

Caused by: java.lang.ClassNotFoundException: javax.jms.MessageListener

From what I've read the messagelistener.class and my library jars should be included in my classpath when the project is running but that doesn't seem to be the case.

1
well, jars are obviously not sources. Check this out stackoverflow.com/questions/2404426/… - leetwinski

1 Answers

1
votes

It is my understanding that the directory structure of java projects has to match the name of the namespaces. For instance package_name.classname has to be in the folder package_name on the classpath https://docs.oracle.com/javase/tutorial/java/package/managingfiles.html

But of course using either Leiningen or Boot you just need to add [javax.jms/jms-api "1.1-rev-1"] to the :dependencies.