惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 李小加

rapidocr_api 在windows下安装 MYSQL 创建用户 配置logging.properties解决浏览器访问tomcat日志文件出现中文乱码问题 linux 安装字体解决JAVA图形中文乱码问题 MySQL 按时间段统计SQL maven 本地库添加jar包 数据接口开发管理平台(starAPI) oracle 11g https://localhost:1158/em 无法访问 & 设置自增id 第三方开源小工具 静态代码检查 mysql 数据库集群连接配置 tomcat server.xml 配置优化 使用PowerDesigner16.5 逆向数据库生产表结构或导出word文档 SpringBoot、thymeleaf 国际化配置 解决 SpringBoot 跨域请求问题 在 centos7 系统中用 docker 创建 tomcat 服务镜像 JAVA 调用 com.google.protobuf mysql 删除多个字段重复的数据, 只保留最新的一条 Git linux服务端安装、windows 用户端使用
linux 系统上图形生成错误 java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
李小加 · 2024-06-02 · via 博客园 - 李小加

错误信息:

02-Jun-2024 09:11:09.421 SEVERE [Thread-32] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [springDispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment] with root cause
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment

原因分析:

验证码采用awt图形处理并内存中生成,java程序会去寻找linux上的图形界面是否启动 ,如linux缺少组件则, 缺少了显示设备、键盘或鼠标会报这个错误;

所以需要开启无头模式, Headless模式是系统的一种配置模式 , 开始激活headless模式,告诉程序,现在你要工作在Headless mode下,就不要指望硬件帮忙了,你得自力更生,依靠系统的计算能力模拟出这些特性来继续;

解决方案:

jar启动时,增加如下命令:

-Djava.awt.headless=true
war包启动,更改tomcat/bin/catalina.sh的文件,增加:

JAVA_OPTS="$JAVA_OPTS -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Djava.awt.headless=true"