While I'm far from a java classpath-related issues problem, I think I know enough to say that placing your libs in the java.ext.dirs classpath is a trick that could lead to problems.
It's primary and sole intent is to hold extensions to the java API that then would be loaded with the core java APIs. That's certainly why you're having problems when you mess up the dependencies in places where there is a hierarchy of classloaders involved : clojure-contrib was loaded with the "main classloader" along with java core libraries, and clojure was loaded with a "child" classloader. And thus clojure-contrib classes were not able to see any of the classes in the child classloader. The problem with this java.ext.dirs is of the category of problems pointed out by C. Martin (and others!) as a design smell : the one named "viscosity" : "doing things right is harder than doing things wrong". It's so easy to put everything in this java.ext.dirs directory that it's difficult resisting the temptation ! Regards, -- Laurent 2009/6/27 Chouser <chou...@gmail.com>: > When I starting Clojure, I generally point -Djava.ext.dirs > at a "classpaths" directory. That's where I dump jars, > symlinks to jars, and symlinks to the 'src' and 'classes' > directories of the various projects I have installed. > > I know that some people have had trouble with java.ext.dirs > and instead use wildcards in their classpaths or other more > complicated solutions. But since I've never seen these > problems described in enough detail to reproduce or > troubleshoot, when I stumbled on one tonight I thought it'd > be worth documenting... > > Here is the simplest way I've found to produce the error I'm > seeing: > > 1. Compile clojure-contrib > 2. Create a "classpaths" directory with symlink to > clojure-contrib/classes, so as to add the compiled contrib > classes to the classpath. Mine lookes like this: > > $ ls -l classpaths/ > total 0 > lrwxrwxrwx 1 chouser chouser 32 2009-06-27 00:54 classes -> > ../proj/clojure-contrib/classes/ > > 3. Start clojure and try to use something from contrib: > > java -Djava.ext.dirs=classpaths -cp proj/clojure/clojure.jar clojure.main > user=> (require 'clojure.contrib.math) > java.lang.NoClassDefFoundError: clojure/lang/RT (NO_SOURCE_FILE:0) > > The full stack trace for that exception is attached. > > > I've found two workarounds so far. Take your pick: > > A. Add clojure.jar to the "classpaths" directory. Once > that's done, it doesn't matter if you also specify it in -cp > on the java command line or not: > > $ ls -l classpaths/ > total 0 > lrwxrwxrwx 1 chouser chouser 32 2009-06-27 00:54 classes -> > ../proj/clojure-contrib/classes/ > lrwxrwxrwx 1 chouser chouser 27 2009-06-27 01:06 clojure.jar -> > ../proj/clojure/clojure.jar > > B. Remove the contrib link from "classpaths" and specify it > on the java command line instead: > > java -Djava.ext.dirs=classpaths -cp proj/clojure-contrib/classes clojure.main > > --Chouser > > > > --~--~---------~--~----~------------~-------~--~----~ 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 Note that posts from new members are moderated - please be patient with your first post. 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 -~----------~----~----~----~------~----~------~--~---