Trouble compiling clojure.contrib libs

1 view
Skip to first unread message

Stephen C. Gilardi

unread,
Nov 25, 2008, 9:02:59 AM11/25/08
to clo...@googlegroups.com
I'm having trouble compiling code from clojure-contrib. Here's a
reproducible example based on the current svn heads of each (1121, 257).

% cd /tmp
% svn co https://clojure.svn.sourceforge.net/svnroot/clojure/trunk
clojure > /dev/null
% svn co https://clojure-contrib.svn.sourceforge.net/svnroot/clojure-contrib/trunk
clojure-contrib > /dev/null
% cd clojure
% ant > /dev/null
% java -cp clojure.jar:/tmp/clojure-contrib/src:/tmp/myclasses
clojure.lang.Repl
Clojure
user=> (require 'clojure.contrib.except) ; same behavior
with or without this line, just showing that clojure.contrib is
accessible
nil
user=> (binding [*compile-path* "/tmp/myclasses"] (compile
'clojure.contrib.except))
java.lang.RuntimeException: java.lang.ClassNotFoundException:
clojure.contrib.except$throwf__35 (NO_SOURCE_FILE:0)
user=> (System/getProperty "java.class.path")
"clojure.jar:/tmp/clojure-contrib/src:/tmp/myclasses"
user=> (binding [*compile-path* "/tmp/myclasses"] (compile
'clojure.contrib.except))
java.lang.RuntimeException: java.lang.ClassNotFoundException:
clojure.contrib.except$throwf__44 (NO_SOURCE_FILE:0)
user=>
% ls -R /tmp/myclasses
clojure

/tmp/myclasses/clojure:
contrib

/tmp/myclasses/clojure/contrib:
except$throwf__35.class except$throwf__44.class except.class
% java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)

The ClassNotFoundException is thrown even though it appears that the
class should be found. A class file with that name exists in the
(global) classpath. The example shown is Mac OS X Leopard. The failure
is exactly the same on Ubuntu 8.10 Linux with this java -version:

% java -version
java version "1.6.0_0"
IcedTea6 1.3.1 (6b12-0ubuntu6) Runtime Environment (build 1.6.0_0-b12)
OpenJDK Client VM (build 1.6.0_0-b12, mixed mode, sharing)

--Steve

Chouser

unread,
Nov 25, 2008, 11:38:02 AM11/25/08
to clo...@googlegroups.com
On Tue, Nov 25, 2008 at 9:02 AM, Stephen C. Gilardi <sque...@mac.com> wrote:
>
> % java -cp clojure.jar:/tmp/clojure-contrib/src:/tmp/myclasses
> clojure.lang.Repl

The classes directory ("/tmp/myclasses" in this case) must exist
before you start Java with it in your classpath. You get no error at
this point, but apparently if the directory doesn't exist it's not
really used, even though it's shown in the java.class.parth property
string.

--Chouser

Stephen C. Gilardi

unread,
Nov 25, 2008, 11:59:25 AM11/25/08
to clo...@googlegroups.com

Thanks, that works great! It also explains why the ant build works--it
always creates the directory first.

Unless this changes, perhaps the Clojure AOT mechanism should refuse
to create the directory at *compile-path* and instead require that it
already exist. That would catch many instances of this problem and
could provide a helpful message.

Is there any way Clojure can add *compile-path* to classpath at the
correct level so it's recognized in all the places it needs to be? I
gather if that were easy, Rich would have already done it.

Any ideas?

--Steve

Reply all
Reply to author
Forward
0 new messages