linux 环境 java web 验证码失效

时间:2024-03-08 20:30:30

访问验证码报错:

2020-07-05 20:09:05.610 ERROR 23483 --- [nio-8877-exec-8] c.z.m.a.c.h.ExceptionHandlerAdvice       : Exception:Handler dispatch failed; nested exception is j
ava.lang.UnsatisfiedLinkError: /usr/java/jdk1.8.0_181/jre/lib/i386/libfontmanager.so: libgcc_s.so.1: cannot open shared object file: No such file or directory

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.UnsatisfiedLinkError: /usr/java/jdk1.8.0_181/jre/l
ib/i386/libfontmanager.so: libgcc_s.so.1: cannot open shared object file: No such file or directory
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1053)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
 ...

2020-07-05 20:11:00.232 ERROR 23483 --- [nio-8877-exec-5] c.z.m.a.c.h.ExceptionHandlerAdvice       : Exception:Handler dispatch failed; nested exception is j
ava.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class s
un.awt.X11FontManager
 ...

在解决过程中尝试了以下方法,但是没效果。

  • java 命令后面追加 -Djava.awt.headless=true
  • 在验证码方法class添加
static {
    System.setProperty("java.awt.headless", "true");
}

我的解决办法是在linux中安装以下:

[root@zwz /]# yum install libgcc.i686 --setopt=protected_multilib=false
[root@zwz /]# yum grouplist 
[root@zwz /]# yum groupinstall Font