我尝试从独立的 swing 客户端(在客户端机器上的单独 JVM 中运行)连接到 Glassfish 服务器。
我目前使用 Netbeans 的以下设置,一切正常:
System.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
System.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
System.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
System.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.1.3");
System.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext context = new InitialContext();
但是当我尝试通过键入“java -jar client.jar”从控制台启动编译的客户端时,我收到以下错误:
D:\workspace\gf-client\dist>java -jar gf-client.jar
17.08.2012 11:07:38 ch.client.core.ServerContext getInitialContext SCHWERWIEGEND: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at ch.lawsuite.core.ServerContext.getInitialContext(ServerContext.java:2 7)
at ch.client.core.remote.Facades.initialize(Facades.java:68)
at ch.client.core.Client.main(Client.java:57) Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialIni tContextFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 7 more Exception in thread "main" java.lang.NullPointerException
at ch.client.core.remote.Facades.initialize(Facades.java:69)
at ch.client.core.Client.main(Client.java:57)
有人有什么有用的想法吗?
- JVM 是否遗漏了任何库?哪个?(它从 netbeans 工作,所有依赖的库都打包到编译的 jar 文件中(至少我这么认为..))
- Glassfish 是否有替代的串行上下文工厂?
非常感谢您提前提供的帮助!