kaptcha,使用图像验证码com.github.penggle组件。
<!-- 验证码 -->
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>2.3.2</version>
<exclusions>
<exclusion>
<artifactId>javax.servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
</exclusions>
</dependency>
在本地windows 开发环境没问题,但是发布到本地测试环境linux服务器时报了异常:
23:07:32.887 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [logArray,53] - Handler dispatch failed; nested exception is java.lang.InternalError: java.lang.reflect.InvocationTargetException
23:07:32.898 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1085)
23:07:32.898 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
23:07:32.899 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
23:07:32.899 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
23:07:32.900 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
23:07:32.900 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
23:07:32.900 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
23:07:32.900 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
23:07:32.901 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
23:07:32.902 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
23:07:32.902 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
23:07:32.902 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
23:07:32.902 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:114)
23:07:32.902 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
23:07:32.903 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
23:07:32.903 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
23:07:32.903 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
23:07:32.903 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
23:07:32.903 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
23:07:32.903 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
23:07:32.903 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
23:07:32.904 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
23:07:32.904 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
23:07:32.904 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:126)
23:07:32.904 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:64)
23:07:32.904 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:101)
23:07:32.904 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
23:07:32.904 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:119)
23:07:32.905 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
23:07:32.905 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
23:07:32.905 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
23:07:32.905 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
23:07:32.905 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
23:07:32.905 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
23:07:32.905 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
23:07:32.906 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
23:07:32.906 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
23:07:32.906 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
23:07:32.906 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
23:07:32.906 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
23:07:32.906 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
23:07:32.906 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
23:07:32.906 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
23:07:32.907 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
23:07:32.907 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889)
23:07:32.911 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)
23:07:32.911 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
23:07:32.911 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
23:07:32.911 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
23:07:32.911 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
23:07:32.911 [http-nio-8080-exec-6] ERROR c.t.f.e.GlobalExceptionHandler - [lambda$logArray$0,54] - java.base/java.lang.Thread.run(Thread.java:834)
解决办法:生成的图型验证码需要用到字体文
yum install fontconfig #安装字体配置组件
reboot #重启服务器生效