• web项目部署在centos 7验证码显示不出来解决方案


    今天把项目部署在centos7上,发现验证码显示不出来,看了一下tomcat日志

    Exception in thread "http-nio-8080-exec-3" java.lang.InternalError: java.lang.reflect.InvocationTargetException
    at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:86)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
    at java.desktop/java.awt.Font.getFont2D(Font.java:497)
    at java.desktop/java.awt.Font$FontAccessImpl.getFont2D(Font.java:237)
    at java.desktop/sun.font.FontUtilities.getFont2D(FontUtilities.java:139)
    at java.desktop/sun.java2d.SunGraphics2D.checkFontInfo(SunGraphics2D.java:670)
    at java.desktop/sun.java2d.SunGraphics2D.getFontInfo(SunGraphics2D.java:831)
    at java.desktop/sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:46)
    at java.desktop/sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2929)
    at com.itheima.travel.web.servlet.PicCodeServlet.doPost(PicCodeServlet.java:55)
    at com.itheima.travel.web.servlet.PicCodeServlet.doGet(PicCodeServlet.java:75)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    Exception in thread "http-nio-8080-exec-3" java.lang.InternalError: java.lang.reflect.InvocationTargetException
        at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:86)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
        at java.desktop/java.awt.Font.getFont2D(Font.java:497)
        at java.desktop/java.awt.Font$FontAccessImpl.getFont2D(Font.java:237)
        at java.desktop/sun.font.FontUtilities.getFont2D(FontUtilities.java:139)
        at java.desktop/sun.java2d.SunGraphics2D.checkFontInfo(SunGraphics2D.java:670)
        at java.desktop/sun.java2d.SunGraphics2D.getFontInfo(SunGraphics2D.java:831)
        at java.desktop/sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:46)
        at java.desktop/sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2929)
        at com.itheima.travel.web.servlet.PicCodeServlet.doPost(PicCodeServlet.java:55)
        at com.itheima.travel.web.servlet.PicCodeServlet.doGet(PicCodeServlet.java:75)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)


    发现应该是字体问题,windows下的字体在centos上并没有.

    1,首先把需要的字体复制到**“/usr/share/fonts”**目录中

    2,修改字体文件的权限,使root用户以外的用户也可以使用:

    cd /usr/share/fonts/windows

    chmod 755 *.ttc

    3,建立字体缓存

    mkfontscale (如果提示 命令不存在,安装 # yum install mkfontscale )

    mkfontdir

    fc-cache -fv (如果提示 命令不存在,安装# yum install fontconfig )

    4、重启计算机

    解决

  • 相关阅读:
    css3--简单的加载动画
    background--详解(背景图片根据屏幕的自适应)
    css--两行显示省略号兼容火狐浏览器
    tortoisegit--无法commit
    vim--学习
    JavaScript--数据结构与算法之图
    JSONP
    数据结构--只用位运算实现加减乘除操作
    剑指offer——不用加减乘除做加法
    shop--10.前端展示系统--首页展示(后台)
  • 原文地址:https://www.cnblogs.com/dfsxh/p/11423538.html
Copyright © 2020-2023  润新知