java.awt.HeadlessException错误

解决验证码显示问题
本文介绍了解决因java.awt.HeadlessException导致的验证码无法显示的问题。通过调整Tomcat和Resin服务器的配置文件,将-Djava.awt.headless参数设置为false,成功解决了绘图错误。

项目中换了个环境登录页面的验证码就出不来了。

跟踪进去,发现java.awt.HeadlessException绘图出错了,

上网搜索。结果如下:

把tomat/bin下的catalina.bat中的

set JAVA_OPTS=-Xms256m -Xmx512m -Djava.awt.headless=true

改为

set JAVA_OPTS=-Xms256m -Xmx512m -Djava.awt.headless=falsh

就OK了

 

resin 3.1.X版本

在resin.conf中配置

      <jvm-arg>-Xmx256m</jvm-arg>
      <jvm-arg>-Xss1m</jvm-arg>
      <jvm-arg>-Xdebug</jvm-arg>
      <jvm-arg>-Djava.awt.headless=falsh</jvm-arg>

就好了

OpenJDK 64-Bit Server VM warning: Archived non-system classes are disabled because the java.system.class.loader property is specified (value = "com.intellij.util.lang.PathClassLoader"). To use archived non-system classes, this property must not be set 2025-04-01 09:15:16,701 [ 151] SEVERE - #c.i.u.s.SvgCacheManager - Cannot create SvgCacheManager kotlinx.coroutines.JobCancellationException: Parent job is Cancelling; job=UndispatchedCoroutine{Cancelling}@706d4d07 Caused by: java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it. at java.desktop/java.awt.dnd.DragSource.getDefaultDragSource(DragSource.java:226) at com.intellij.platform.ide.bootstrap.UiKt$scheduleUpdateFrameClassAndWindowIconAndPreloadSystemFonts$1$3.invokeSuspend(ui.kt:255) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDis
04-02
[0.008s][warning][cds] Archived non-system classes are disabled because the java.system.class.loader property is specified (value = "com.intellij.util.lang.PathClassLoader"). To use archived non-system classes, this property must not be set 2025-09-04 19:34:52,703 [ 48] WARN - #c.i.p.i.b.AppStarter - Unable to load JNA library (Linux/6.8.0-78-generic, jna.boot.library.path=/home/user/pycharm-2025.2.1.1/lib/jna/aarch64) java.lang.UnsatisfiedLinkError: Unable to locate JNA native support library at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:1014) at com.sun.jna.Native.<clinit>(Native.java:221) at com.intellij.jna.JnaLoader.load(JnaLoader.java:29) at com.intellij.platform.ide.bootstrap.StartupUtil$scheduleLoadSystemLibsAndLogInfoAndInitMacApp$1$2.invokeSuspend(startup.kt:353) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100) at kotlinx.coroutines.internal.SoftLimitedDispatcher$Worker.run(SoftLimitedDispatcher.kt:130) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:613) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:1183) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:778) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:765) **Start Failed** Internal error java.awt.HeadlessException: No X11 DISPLAY variable was set, or no headful library support was found, but this program performed an operation which requires it, at java.desktop/java.awt.dnd.DragSource.getDefaultDragSource(DragSource.java:226) at com.intellij.platform.ide.bootstrap.UiKt$scheduleUpdateFrameClassAndWindowIconAndPreloadSystemFonts$1$3.invokeSuspend(ui.kt:267) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:276) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) ----- JRE: 21.0.8+9-Ubuntu-0ubuntu122.04.1 amd64 (Ubuntu) /usr/lib/jvm/java-21-openjdk-amd64
最新发布
09-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值