Java EE Glassfish - NullPointerException 因为 "dcs" 未找到

Java EE Glassfish - NullPointerException because "dcs" not found

尝试 运行 asadmin 时收到此错误:

/opt/glassfish5/bin $ ./asadmin start-domain
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.glassfish.hk2.api.DynamicConfigurationService.createDynamicConfiguration()" because "dcs" is null
    at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.initializeServiceLocator(AbstractModulesRegistryImpl.java:152)
    at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.newServiceLocator(AbstractModulesRegistryImpl.java:144)
    at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:218)
    at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:224)
    at com.sun.enterprise.module.single.StaticModulesRegistry.createServiceLocator(StaticModulesRegistry.java:88)
    at com.sun.enterprise.admin.cli.CLIContainer.getServiceLocator(CLIContainer.java:217)
    at com.sun.enterprise.admin.cli.CLIContainer.getLocalCommand(CLIContainer.java:255)
    at com.sun.enterprise.admin.cli.CLICommand.getCommand(CLICommand.java:231)
    at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:371)
    at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:306)
    at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:57)

我的JavaJDK:

$ readlink -f $(which java)
/usr/lib/jvm/java-17-openjdk-amd64/bin/java

我尝试将 AS_JAVA="/usr/lib/jvm/java-17-openjdk-amd64" 添加到 asenv.conf 文件,但错误仍然存​​在。有什么帮助吗? 哦,是的,我在 /opt/glassfish5/glassfish/bin/opt/glassfish5/bin 中都没关系,错误是相同的

好的,您只需要使用 Java SDK 1.8

GlassFish 5 不支持 JDK 17,但最新版本的 GlassFish 6 支持。如果可能,请尝试升级到 GlassFish 6.2.4,这是撰写本文时的最新版本。