我正在尝试用 389 DS 替换一些古老的 SunOne 目录服务器。我有一个全新的 CentOS 安装,我按照概述的步骤进行操作这里。我的工作站是 RHEL7,我在那里安装了 389-console,以便远程连接到前面提到的新 LDAP 服务器。
但是当我尝试在本地启动 389-console 时,出现了错误java.awt.HeadlessException
。我在 google abit 上搜索了一下,几乎所有我见过的帖子都遇到了同样的问题,只是他们尝试通过 X 转发 389-console。
我希望这可以在本地启动而不会出现任何问题,并且错误似乎与远程连接有关:
mose@localhost ~ $ 389-console
Exception in thread "main" java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
at java.awt.Window.<init>(Window.java:536)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.JFrame.<init>(JFrame.java:189)
at com.netscape.management.client.console.Console.<init>(Unknown Source)
at com.netscape.management.client.console.Console.main(Unknown Source)
工作站特定信息:
mose@localhost ~ $ cat /etc/redhat-release
Red Hat Enterprise Linux Client release 7.3 (Maipo)
mose@localhost ~ $ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b31)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b31, mixed mode)
mose@localhost ~ $ env | grep -i display
DISPLAY=:0
mose@localhost ~ $ sudo rpm -qa | grep 389
389-console-1.1.18-1.el7.noarch
mose@localhost ~ $ sudo rpm -qa | grep xauth
xorg-x11-xauth-1.0.9-1.el7.x86_64
我正在运行 KDE 作为我的 GUI。我还更改了我正在使用的 Java update-alternatives(在 openJDK 和 oracleJDK 之间)。
完整的调试跟踪如下:
mose@workstation ~ $ 389-console -D 9
java.util.prefs.userRoot=/home/mose/.389-console
java.runtime.name=OpenJDK Runtime Environment
sun.boot.library.path=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/amd64
java.vm.version=25.121-b13
java.vm.vendor=Oracle Corporation
java.vendor.url=http://java.oracle.com/
path.separator=:
java.vm.name=OpenJDK 64-Bit Server VM
file.encoding.pkg=sun.io
user.country=US
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=unknown
java.vm.specification.name=Java Virtual Machine Specification
user.dir=/home/mose
java.runtime.version=1.8.0_121-b13
java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment
java.endorsed.dirs=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/endorsed
os.arch=amd64
java.io.tmpdir=/tmp
line.separator=
java.vm.specification.vendor=Oracle Corporation
os.name=Linux
sun.jnu.encoding=UTF-8
java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.specification.name=Java Platform API Specification
java.class.version=52.0
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
os.version=3.10.0-514.10.2.el7.x86_64
user.home=/home/mose
user.timezone=America/New_York
java.awt.printerjob=sun.print.PSPrinterJob
file.encoding=UTF-8
java.specification.version=1.8
java.class.path=/usr/lib/java/jss4.jar:/usr/share/java/ldapjdk.jar:/usr/share/java/idm-console-base.jar:/usr/share/java/idm-console-mcc.jar:/usr/share/java/idm-console-mcc_en.jar:/usr/share/java/idm-console-nmclf.jar:/usr/share/java/idm-console-nmclf_en.jar:/usr/share/java/389-console_en.jar
user.name=michael.moser
java.vm.specification.version=1.8
sun.java.command=com.netscape.management.client.console.Console -D 9
java.home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre
sun.arch.data.model=64
java.util.prefs.systemRoot=/home/mose/.389-console
user.language=en
java.specification.vendor=Oracle Corporation
awt.toolkit=sun.awt.X11.XToolkit
java.vm.info=mixed mode
java.version=1.8.0_121
java.ext.dirs=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/resources.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/rt.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/jce.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/jfr.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/classes
java.awt.headless=true
java.vendor=Oracle Corporation
file.separator=/
java.vendor.url.bug=http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding=UnicodeLittle
sun.cpu.endian=little
sun.cpu.isalist=
389-Management-Console/1.1.17 B2016.291.2035
RemoteImage: NOT found in cache loader589431969:com/netscape/management/nmclf/icons/Error.gif
RemoteImage: Create RemoteImage cache for loader589431969
RemoteImage: NOT found in cache loader589431969:com/netscape/management/nmclf/icons/Inform.gif
RemoteImage: NOT found in cache loader589431969:com/netscape/management/nmclf/icons/Warn.gif
RemoteImage: NOT found in cache loader589431969:com/netscape/management/nmclf/icons/Question.gif
ResourceSet: NOT found in cache loader589431969:com.netscape.management.client.components.components
Exception in thread "main" java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
at java.awt.Window.<init>(Window.java:536)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.JFrame.<init>(JFrame.java:189)
at com.netscape.management.client.console.Console.<init>(Unknown Source)
at com.netscape.management.client.console.Console.main(Unknown Source)
答案1
我在调试跟踪中发现,尽管为 oracle JRE 配置了 update-alternatives,但 389-console 使用的是 openJDK。虽然安装了 openJDK,但我只有它的无头版本,这不足以运行 AWT 库
答案2
问题在于:
sun.boot.library.path=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64/jre/lib/amd64
java.vm.version=25.121-b13
创建此变量:
export JAVA_HOME="DIRECTORY OF ORACLE JAVA"
然后再次运行:
389-console -D 9