javax.naming.NoInitialContextException: 无法实例化 class: com.sun.enterprise.naming.SerialInitContextFactory

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory

我正在部署一个使用 EJB 的应用程序。我已经编写了一个 EJB 和一个要连接的 java 独立客户端。在 Netbeans 中一切正常,但是当我尝试在命令行中启动时出现异常。 JavaFX 应用程序包含以下代码:

    String chemin = IRemoteInterface.class.getName();
    Properties vEnv = new Properties();
    vEnv.put("org.omg.CORBA.ORBInitialHost", "localhost");
    vEnv.put("org.omg.CORBA.ORBInitialPort", "3700");

    try {
        Context ctx = new InitialContext(vEnv);
        leProxy = (IRemoteInterface) ctx.lookup(chemin);
        System.out.println("proxy OK");
    } catch (NamingException ex) {
        System.out.println("erreur proxy");
        Logger.getLogger(CDM.class.getName()).log(Level.SEVERE, null, ex);
    }

我尝试了以下方法:

java -jar CDM.jar

我得到的错误是:

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.impl.SerialInitContextFactory [Root exception is java.lang.NullPointerException]
    at java.naming/javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at java.naming/javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at java.naming/javax.naming.InitialContext.init(Unknown Source)
    at java.naming/javax.naming.InitialContext.<init>(Unknown Source)
    at cdm.CDM.main(CDM.java:77)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.NullPointerException
    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 org.glassfish.internal.api.Globals.getStaticHabitat(Globals.java:102)
    at com.sun.enterprise.naming.impl.SerialInitContextFactory.<init>(SerialInitContextFactory.java:130)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.base/java.lang.Class.newInstance(Unknown Source)
    ... 16 more

我真的不知道怎么解决。

非常感谢您的提前帮助!

编辑:

当我使用以下内容时它有效

java -cp "C:\Program Files\glassfish5\glassfish\lib\appserv-rt.jar;C:\Program Files\glassfish5\glassfish\lib\javaee.jar;C:\Program Files\glassfish5\glassfish\lib\gf-client.jar;CDM.jar" cdm.CDM