服务器ip地址变了后,上传数据时涉及到画图部分,系统抛出以下异常:
Caused by: java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
at sun.font.FontManager.initSGEnv(FontManager.java:1094)
at sun.font.FontManager.findFont2D(FontManager.java:1756)
at java.awt.Font.getFont2D(Font.java:452)
at java.awt.Font.canDisplay(Font.java:1835)
at java.awt.Font.canDisplayUpTo(Font.java:1901)
at java.awt.font.TextLayout.singleFont(TextLayout.java:451)
at java.awt.font.TextLayout.(TextLayout.java:509)
头一回遇到这样的异常,有点蒙。之前都是好好的,ip地址更换应该对它没有影响啊,各种百度之后,才有点眉目。tomcat调用X-Server画图服务时,该项服务没有开启,所以才有以上异常,知道原因后,找到tomcat安装目录的bin文件夹,编辑catalina.sh文件,添加以下代码:CATALINA_OPTS=”-Djava.awt.headless=true”,重启tomcat,问题得到解决。具体添加位置如下:
# LOGGING_CONFIG (Optional) Override Tomcat's logging config file
# Example (all one line)
# LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
#
# LOGGING_MANAGER (Optional) Override Tomcat's logging manager
# Example (all one line)
# LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
#
# $Id: catalina.sh 1146097 2018-07-02 17:25:05Z markt $
# -----------------------------------------------------------------------------
JAVA_OPTS="-Xms512m -Xmx19500m"
CATALINA_OPTS="-Djava.awt.headless=true"
# OS specific support. $var _must_ be set to either true or false.
cygwin=false
os400=false
darwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
Darwin*) darwin=true;;
esac
# resolve links - $0 may be a softlink
PRG="$0"
while [ -h "$PRG" ]; do