word is too tall: try to use less letters, smaller font or bigger background 报错 java程序 验证码不显示

验证码不现实问题爆发在测试站,还好只是个测试站,有时间让我慢慢研究此问题。

具体的情况是这样的:

下午三点多,突然测试人员跟我说,测试站后台的验证码不现实了,也就无法登陆了
通过询问,是中午吃饭前还是好好的,突然就不能用了。

紧接着查看tomcat后台日志

java程序突然报错,报错信息如下:

[2018-06-27 21:08:15,318] http-bio-8480-exec-1 (ActionInterceptor.java:105) ERROR - Exception className :com.rongdu.web.action.ToolAction
[2018-06-27 21:08:15,318] http-bio-8480-exec-1 (ActionInterceptor.java:106) ERROR - Exception methodName:validimg
[2018-06-27 21:08:15,319] http-bio-8480-exec-1 (ActionInterceptor.java:107) ERROR - Exception message :
com.octo.captcha.CaptchaException: word is too tall: try to use less letters, smaller font or bigger background: text bounds = {text=0438
java.awt.geom.Rectangle2D$Float[x=0.0,y=-26.076172,w=20.198242,h=38.13672] ascent=26.076172 descent=12.060547 leading=-0.0
java.awt.geom.Rectangle2D$Float[x=40.198242,y=-26.076172,w=21.632812,h=38.13672] ascent=26.076172 descent=12.060547 leading=-0.0
java.awt.geom.Rectangle2D$Float[x=81.831055,y=-26.076172,w=20.198242,h=38.13672] ascent=26.076172 descent=12.060547 leading=-0.0
java.awt.geom.Rectangle2D$Float[x=122.0293,y=-26.076172,w=7.147461,h=38.13672] ascent=26.076172 descent=12.060547 leading=-0.0
} with fonts {java.awt.Font[family=Dialog,name=Verdana,style=bold,size=26]
java.awt.Font[family=Dialog,name=Arial,style=italic,size=26]
java.awt.Font[family=Dialog,name=Verdana,style=italic,size=26]
java.awt.Font[family=Dialog,name=Tahoma,style=bold,size=26]
} versus image width = 80, height = 37
at com.octo.captcha.image.gimpy.GimpyFactory.getImageCaptcha(GimpyFactory.java:79)
at com.octo.captcha.engine.image.ImageCaptchaEngine.getNextCaptcha(ImageCaptchaEngine.java:73)
at com.octo.captcha.service.AbstractCaptchaService.generateAndStoreCaptcha(AbstractCaptchaSe
..............................................................................
..............................................................................
报错信息太多,只截取一节;

这个问题困扰了我四个小时,是突然下午不能访问的,因为这期间测试站上线过一个版本

经过重启Tomcat无效后,决定回退测试,结果显然意见,依旧是失败,报错,不现实验证码;

为解决此问题,下班了公司人都走了,我还在公司继续看,因为不解决,影响第二天的测试;

一直到九点多,都没有找到原因,打电话咨询一个java开发的朋友技术很吊,把报错及问题说了一下,他说遇到过,应该是字体的问题,回头仔细翻看日志,分析日志,发现。。。。
下面三行报错代码:

java.awt.Font[family=Dialog,name=Arial,style=italic,size=26]
java.awt.Font[family=Dialog,name=Verdana,style=italic,size=26]
java.awt.Font[family=Dialog,name=Tahoma,style=bold,size=26]

然后把name的三个字体在windows下找到,放到centos下,在/usr/share/fonts/ 下创建三个目录,分别把三个字体的文件存放进去,然后执行 fc-cache 重新加载字体;

[root@bogon fonts]# pwd
/usr/share/fonts
[root@bogon fonts]# ls
arial lyx tahoma Verdana
[root@bogon fonts]# fc-cache

解决;

猜你喜欢

转载自www.cnblogs.com/winstom/p/9237315.html