aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes JCaptcha image not displays on heavy load Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "JCaptcha image not displays on heavy load" Watch "JCaptcha image not displays on heavy load" New topic
Author

JCaptcha image not displays on heavy load

Rashmi Umre
Greenhorn

Joined: Jul 20, 2006
Posts: 17
Hello All,

We are facing issue in our live site related to display captcha image in site. It works fine in other environment suddenly this issue started in production now. This issues starts when production server has heavy loads and below exceptrion stops displaying captcha image. Restarting of server starts displaying captcha image.

We are using JCaptcha 2.0.jar and

We created servlet which generate image by using jcaptcha library. We have our own code generator which randomly generates character and number combination code. By using captcha library we convert into image and displays to web page.

TextPaster randomPaster = new GlyphsPaster(Integer.valueOf(7), Integer.valueOf(7), new RandomListColorGenerator(new Color[] {
new Color(23, 170, 27), new Color(220, 34, 11), new Color(23, 67, 172)
}), new GlyphsVisitors[] {
new TranslateGlyphsVerticalRandomVisitor(1.0D), new OverlapGlyphsUsingShapeVisitor(3D), new TranslateAllToRandomPointVisitor()
});
BackgroundGenerator back = new UniColorBackgroundGenerator(Integer.valueOf(200), Integer.valueOf(70), Color.white);
FontGenerator shearedFont = new RandomFontGenerator(Integer.valueOf(50), Integer.valueOf(50), new Font[] {
new Font("nyala", 1, 50), new Font("Bell MT", 0, 50), new Font("Credit valley", 1, 50)
}, false);
PinchFilter pinch = new PinchFilter();
pinch.setAmount(-0.5F);
pinch.setRadius(70F);
pinch.setAngle(0.1963495F);
pinch.setCentreX(0.5F);
pinch.setCentreY(-0.01F);
pinch.setEdgeAction(1);
PinchFilter pinch2 = new PinchFilter();
pinch2.setAmount(-0.6F);
pinch2.setRadius(70F);
pinch2.setAngle(0.1963495F);
pinch2.setCentreX(0.3F);
pinch2.setCentreY(1.01F);
pinch2.setEdgeAction(1);
PinchFilter pinch3 = new PinchFilter();
pinch3.setAmount(-0.6F);
pinch3.setRadius(70F);
pinch3.setAngle(0.1963495F);
pinch3.setCentreX(0.8F);
pinch3.setCentreY(-0.01F);
pinch3.setEdgeAction(1);
java.util.List textDef = new ArrayList();
textDef.add(new ImageDeformationByBufferedImageOp(pinch));
textDef.add(new ImageDeformationByBufferedImageOp(pinch2));
textDef.add(new ImageDeformationByBufferedImageOp(pinch3));

WordToImage word2image = new DeformedComposedWordToImage(false, shearedFont, back, randomPaster,

new ArrayList(), new ArrayList(), textDef);
//Error throws in getimage() call.

BufferedImage bi = word2image.getImage(codeVerifier);


Error Trace:
java.lang.NullPointerException
at com.jhlabs.image.TransformFilter.getPixel(TransformFilter.java:139)
at com.jhlabs.image.TransformFilter.filter(TransformFilter.java:116)
at com.jhlabs.image.PinchFilter.filter(PinchFilter.java:105)
at com.octo.captcha.component.image.deformation.ImageDeformationByBufferedImageOp.deformImage(ImageDeformationByBufferedImageOp.java:30)
at com.octo.captcha.component.image.wordtoimage.DeformedComposedWordToImage.getImage(DeformedComposedWordToImage.java:142)
at site.gtech.portal.ui.common.PortalImageCaptchaServlet.doGet(PortalImageCaptchaServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JCaptcha image not displays on heavy load