欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

docker 部署 java web项目到tomcat之后无法显示验证码问题及解决过程 docker tomcat 验证码 

程序员文章站 2022-07-09 17:14:52
...
1、公司新的支付项目采用zookeeper+dubbo微服务架构

2、开发环境和测试环境、模测环境、生产环境采用docker部署

3、今天在和我们的运维一块搭建和调试jenkins+svn+docker+harbor时,遇到我们部署的java web项目的登录验证不能显示问题。

    1)通过在验证码类中记录比较详细的日志,最后排查出是awt库中的java.awt.Graphics2D类,在调用起实例的drawString方法时报了httpstaus 500错误

    2)通过

   https://blog.csdn.net/qq_36836224/article/details/80250220

提供的测试类,在docker中编译此类,得到更精准的异常信息

   bash-4.4# java Graphics2DTest
bash-4.4# java Graphics2DTest         
Exception in thread "main" java.lang.UnsatisfiedLinkError: /jdk/jre/lib/amd64/libfontmanager.so: libgcc_s.so.1: cannot open shared object file: No such file or directory
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at sun.font.FontManagerNativeLibrary$1.run(FontManagerNativeLibrary.java:61)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.font.FontManagerNativeLibrary.<clinit>(FontManagerNativeLibrary.java:32)
        at sun.font.SunFontManager$1.run(SunFontManager.java:339)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.font.SunFontManager.<clinit>(SunFontManager.java:335)
        at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:264)
        at sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:863)
        at Graphics2DTest.main(Graphics2DTest.java:32)


   3)、通过上述错误找到https://blog.soilove.cn/archives/1592.html资料
      跟运维沟通安装libgcc_s.so.1
   4)、安装之后运维反馈继续报错,然后我登录进去docker,执行java Graphics2DTest发现确实依然报,再通过find命令去查 find / -name  libgcc_s.so.1
      发现/usr/lib/libgcc_s.so.1  不在/jdk/jre/lib/amd64/目录下,故此我把libgcc_s.so.1拷贝到/jdk/jre/lib/amd64/目录
   5)、然后继续执行java Graphics2DTest进行测试,发现了新的报错信息
   
bash-4.4# java Graphics2DTest
Exception in thread "main" java.lang.UnsatisfiedLinkError: /jdk/jre/lib/amd64/libfontmanager.so: libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at sun.font.FontManagerNativeLibrary$1.run(FontManagerNativeLibrary.java:61)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.font.FontManagerNativeLibrary.<clinit>(FontManagerNativeLibrary.java:32)
        at sun.font.SunFontManager$1.run(SunFontManager.java:339)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.font.SunFontManager.<clinit>(SunFontManager.java:335)
        at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:264)
        at sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:863)
        at Graphics2DTest.main(Graphics2DTest.java:32)

     
    6)、再把libc.musl-x86_64.so.1拷贝到/jdk/jre/lib/amd64/目录,再执行测试通过
    7)、再验证web验证码服务,发现恢复正常