问题描述:

环境:tomcat8+jdk1.8+centos7.

Failed to instantiate [com.octo.captcha.service.image.DefaultManageableImageCaptchaService]: Constructor threw exception; nested exception is java.lang.ArrayIndexOutOfBoundsException: 0

85拍拍的程序在本地部署没问题,在linux上部署之后,启动报出异常,如下图。实例化DefaultManageableImageCaptchaService失败,该类是spring生成验证码的插件。

部署程序出现Failed to instantiate com.octo.captcha.service.image.DefaultManageableImageCaptchaService-LMLPHP

解决方法:

第一步:在applicationcontext.xml中找到DefaultManageableImageCaptchaService,将其注释,如下图。

部署程序出现Failed to instantiate com.octo.captcha.service.image.DefaultManageableImageCaptchaService-LMLPHP

第二步:找到上图中imageCaptchaService被引用的类,将其引用注释掉。如下图。

部署程序出现Failed to instantiate com.octo.captcha.service.image.DefaultManageableImageCaptchaService-LMLPHP

总结:当启动异常时,看日志只关注了前几行,将重心关注在了shiro的配置上,殊不知该异常是由日志下半部分的DefaultManageableImageCaptchaService 无法实例化引起的连锁反应。所以异常出现时还是要仔细看日志。

部署程序出现Failed to instantiate com.octo.captcha.service.image.DefaultManageableImageCaptchaService-LMLPHP

11-03 17:38