SimpleCaptcha for Servers

Currently there is a bug in SimpleCaptcha library that prevents it running in non-graphics environments. It will throw a java.awt.HeadlessException. Although the code does not rely on various graphics classes, they were left causing this problem.

I fixed the code and recompiled it. You can download the fixed JAR file here. Do not forget to set the system property java.awt.headless to true, e.g. by specifying Djava.awt.headless=true at command line.

Tags: ,

9 Responses to “SimpleCaptcha for Servers”

  1. Stefan Kovachev Says:

    Hey thx man!
    That saved me really a lot of time!

  2. Michael Scheper Says:

    Me too. It’s great when things work out of the box, and when they don’t, that somebody else has fixed it for me. :)

  3. suneel Says:

    HI ,

    I am also using the same simple captcha, but it is getting the previous value rather than current value when i fetch it form session.getAttribute(nl.captcha.servlet.Constants.SIMPLE_CAPCHA_SESSION_KEY)) ;

    should i change any thing

    Thanks,
    Suneel

  4. admin Says:

    Perhaps you have got some session problems? I usually perform:

    String v = (String)request.getSession().getAttribute(nl.captcha.servlet.Constants.SIMPLE_CAPCHA_SESSION_KEY);

    Another problem might be an intraceable session from your request? Check your webapp container whether it enables session tracking.

  5. Xiaoxin Says:

    Many thanks.

  6. Rosario Says:

    Thank you! It does work. I had the same problem and it got fixed with the new jar file. What have you actually changed?

  7. admin Says:

    I removed all unnecessary referrals / attributes from the SimpleCaptcha classes that were referring to graphical display classes. ;-)

  8. Bert Koelewijn Says:

    Hi Ralph,

    You fixed a bug in SimpleCaptcha, so it can be used with headless mode. I am using Kapcha (fork of SimpleCaptcha) on Websphere 5.1, JDK 1.4.2 with -Djava.awt.headless=true. The parameters cannot be changed, because of dependencies with other applications. And I get the java.awt.HeadlessException. What did you change to get it working?

    Thank you for your time!

    Bert

  9. admin Says:

    Hi Bert, see my previous post. ;-)

Leave a Reply