Hi guys got a problem with NPE
I'm having using Kaptcha for drawing captcha ..
public class CaptchaImage extends NonCachingImage {
private static final long serialVersionUID = 1667766853896645923L;
private transient DefaultKaptcha captchaProducer = new
DefaultKaptcha();
// private DefaultKaptcha captchaProducer;
public CaptchaImage(String id) {
super(id);
captchaProducer.setConfig(new Config(new Properties()));
setImageResource(new DynamicImageResource() {
private static final long serialVersionUID =
-3696927797622999885L;
public byte[] getImageData() {
ByteArrayOutputStream os = new
ByteArrayOutputStream();
// write the data out
ImageIO.setUseCache(false);
try {
BufferedImage bi =
getImageCaptchaService();
ImageIO.write(bi, "jpg", os);
return os.toByteArray();
} catch (Exception e) {
throw new RuntimeException(e);
}
};
private BufferedImage getImageCaptchaService() {
Request request =
RequestCycle.get().getRequest();
HttpServletRequest httpRequest = ((WebRequest)
request).getHttpServletRequest();
String capText = captchaProducer.createText();
// store the text in the session
httpRequest.getSession().setAttribute(Constants.KAPTCHA_SESSION_KEY,
capText);
// create the image with the text
BufferedImage bi =
captchaProducer.createImage(capText);
return bi;
}
});
}
}
the problem is that I'm getting NPE on line:
String capText = captchaProducer.createText();
and I can't figure out why ...
can anybody help please ?
Regards
Armando
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/NullPointerException-and-don-t-know-why-tp3701404p3701404.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]