如何为独立客户端设置Glassfish 3.1.2的JNDI? [英] How to setup JNDI for Glassfish 3.1.2 for a stand-alone client?

查看:141
本文介绍了如何为独立客户端设置Glassfish 3.1.2的JNDI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从独立的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:无法实例化类:com.sun.enterprise.naming.SerialInitContextFactory javax.naming.NoInitialContextException:无法实例化class:com。 sun.enterprise.naming.SerialInitContextFactory [根异常是java.lang.ClassNotFoundException:com.sun.enterprise.naming.SerialInitContextFactory] ​​$ b $在javax.naming.spi.NamingManager.getInitialContext(未知源)
at javax.naming.InitialContext.getDefaultInitCtx(未知源)
在javax.naming.InitialContext.init(未知源)
在javax.naming.InitialContext。< init>(未知源)
在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 )由于:java.lang.ClassNotFoundException:com.sun.enterprise.naming.SerialIni tContextFactory $ b $在java.net.URLClassLoader $ 1.run(未知源)
在java.security.AccessController.doPrivileged(本地方法)在java.net.URLClassLoader.findClass上的
(未知源)$ java.util.ClassLoader.loadClass上的
(未知源)$ sun $ m $ b $ sun.misc.Launcher $ AppClassLoader.loadClass(未知源)在java.lang.ClassLoader.loadClass中的
(未知源)在java.lang.Class.forName0中的
(本地方法)$在java.lang.Class.forName中的
(未知源)
在com.sun.naming.internal.VersionHelper12.loadClass(未知源)
... 7更多线程main中的异常java.lang.NullPointerException $ ch.client中的
。 core.remote.Facades.initialize(外墙.java:69)
at ch.client.core.Client.main(Client.java:57)

有人有任何有用的想法?


  • JVM是否会遗漏任何库?哪个? (它从NetBeans工作,所有相关的库都打包到编译的jar文件(至少我认为是这样))

  • Glassfish中是否有其他的串行上下文工厂?
  • >


非常感谢您的帮助!

通过查看gf-client.jar库的MANIFEST.MF文件,我注意到有十几个其他的jar-libs被引用。为了在netbeans平台之外运行客户端,我必须将所有这些库复制到我自己的应用程序的最终版本中。然后,它工作得很好......: - )


I try to connect from a stand-alone swing client (running in a separate JVM on the client machine) to the Glassfish server.

I currently use the following settings from Netbeans and everything works just fine:

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();

But when I try to start the compiled client from the console by typing "java -jar client.jar" I get the following error:

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)

Somebody any helpful idea?

  • Does the JVM miss any libs? Which ones? (it works from netbeans and all dependent libs are packed to the compiled jar-file (at least I think so..))
  • Are there alternative serial context factories for Glassfish ?

Many thanks for your help in advance!

解决方案

By looking into the MANIFEST.MF file of the gf-client.jar library I noticed that there are some dozen other jar-libs referenced from there. In order to run the client outside of the netbeans platform, I had to copy all these libs to the final build of my own application. Then it works just fine... :-)

这篇关于如何为独立客户端设置Glassfish 3.1.2的JNDI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆