MacPorts, Clojure and ClassNotFoundException

After installing Clojure with MacPorts I got the following exception when running a basic Clojure script:

Exception in thread "main" java.lang.NoClassDefFoundError: Pad:/opt/local/share/java/clojure/bin////lib/clojure/jar
Caused by: java.lang.ClassNotFoundException: Pad:.opt.local.share.java.clojure.bin....lib.clojure.jar
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

As it turned out, I had run the script from a folder with a space in it’s name, “Scratch Pad”. After moving the script to an other folder, the script ran just fine.

How to sync MacPorts without rsync

If port 873 is blocked on your network and you need to sync MacPorts do this:

In /opt/local/etc/macports/sources.conf replace

rsync://rsync.macports.org/release/ports/ [default]

with

http://www.macports.org/files/ports.tar.gz [default]

and run

sudo port sync

instead of

sudo port selfupdate

MacPorts is now synching using http over port 80 instead of rsync over port 873.