I am not sure of that but it may come, as Eric suggest, from the import function in core.clj. Indeed this function is based on Class#forName which use Reflection#getCallerClass to find the class loader. May be it uses the application class loader instead of the root class loader of clojure (in which are stored the URL added dynamically), so it can load resources on the application class path but not on url class path added later. Eric's trick of using the source code in another file may have added enough call indirection to enable Class#forName to use the right class loader. May be a debug session could help to find the root cause of the problem
Gaetan On 26 jan, 21:49, bOR_ <boris.sch...@gmail.com> wrote: > Thanks for that solution. Ran into the same problem as well, and right > now I don't want to solve it, but just finish something else. > > On Dec 13 2008, 11:21 pm, Eric Sessoms <nubga...@gmail.com> wrote: > > > Did you ever get this resolved? I just had the same thing start > > happening to me today, after not experiencing any problems with it as > > recently as yesterday. (What changed? I tried to install swank. > > Nuking swank did not fix the problem, tho.) Step by step: > > > (add-classpath ...) ; seems to work, because > > (seq (.getURLs (clojure.lang.RT/baseLoader))) ; shows the added jar or > > directory, and > > (Class/forName ...) ; returns a result (no exception), but > > > (import...) ; fails with ClassNotFoundException and > > (ns (:import...)) ; also fails > > > I eventually got my code working again by copying the source of > > theimportfunction out of core.clj, renaming it "my-import", and changing > > all myimportstatements to "my-import" statements, accordingly. > > > Anyway, it makes no sense to me. I'm just hoping someone more > > experienced will be able to say what's really going on. > > > On Dec 9, 7:07 am, "rob.blackwell" <rob.blackw...@aws.net> wrote: > > > > When I load a JAR at runtime with add-classpath > > > > (add-classpath "file:///Users/reb/java/jena.jar") > > > > and try > > > > user=> (import'(com.hp.hpl.jena.rdf.model ModelFactory)) > > > > I get > > > > java.lang.ClassNotFoundException: > > > com.hp.hpl.jena.rdf.model.ModelFactory (NO_SOURCE_FILE:0) > > > user=> > > > > However, I can still use the classes if I fully qualify them. > > > > The sameimportdoes work if I add the JAR to the classpath when > > > invoking java, but that seems to be less flexible. > > > > Am I doing something wrong? > > > > Is this a bug? > > > > Any advice gratefully received! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---