eclipse glassfish 3,客户端错误
我正在使用最新的 Eclipse 在 Glassfish 3 下开发 EJB 3。我在 Eclipse 中创建一个新的 Glassfish 服务器实例,编写一个简单的 EJB,部署并成功。
现在我写了一个客户端,但它总是给我这样的错误
java.lang.RuntimeException: Orb initialization erorr
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:148)
at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365)
at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.client.Test.main(Test.java:22)
Caused by: java.lang.NullPointerException
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:120)
... 8 more
Exception in thread "main" javax.naming.NamingException: Lookup failed for 'helloRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.lang.RuntimeException: Orb initialization erorr]]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.client.Test.main(Test.java:22)
Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.lang.RuntimeException: Orb initialization erorr]
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:352)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
... 3 more
Caused by: java.lang.RuntimeException: Orb initialization erorr
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:148)
at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365)
at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
... 4 more
Caused by: java.lang.NullPointerException
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:120)
... 8 more
客户端代码是这样
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
InitialContext ic = new InitialContext(props);
HelloRemote remote = (HelloRemote) ic.lookup("helloRemote");
System.out.println(remote.echo("john"));
你知道为什么吗? “com.sun.enterprise.naming.SerialInitContextFactory”不在类路径中吗?
源代码在这里 http://www.mediafire.com/file/278rc1tpip0rjku/EJBApp2.rar
我很感激你的帮助。
I am using latest Eclipse to develop EJB 3 under Glassfish 3. I create a new Glassfish server instance in the Eclipse, write a simple EJB, deployed and succeeded.
Now I write a client, but it always give me error like this
java.lang.RuntimeException: Orb initialization erorr
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:148)
at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365)
at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.client.Test.main(Test.java:22)
Caused by: java.lang.NullPointerException
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:120)
... 8 more
Exception in thread "main" javax.naming.NamingException: Lookup failed for 'helloRemote' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.lang.RuntimeException: Orb initialization erorr]]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.client.Test.main(Test.java:22)
Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.lang.RuntimeException: Orb initialization erorr]
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:352)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
... 3 more
Caused by: java.lang.RuntimeException: Orb initialization erorr
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:148)
at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365)
at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
... 4 more
Caused by: java.lang.NullPointerException
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:120)
... 8 more
the client code is this
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
InitialContext ic = new InitialContext(props);
HelloRemote remote = (HelloRemote) ic.lookup("helloRemote");
System.out.println(remote.echo("john"));
Do you know why ? is it "com.sun.enterprise.naming.SerialInitContextFactory" not in the classpath ?
The source code is here
http://www.mediafire.com/file/278rc1tpip0rjku/EJBApp2.rar
I appreciate your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要解决这个问题,只需在客户端的buildpath中添加外部jar“appserv-rt.jar”即可。
您可以在文件夹 ...\glassfishv3\glassfish\lib 中找到它
,或者使用此 jar 及其所有依赖项创建一个包,以将其添加到 BP
这是我的代码
没有 jar 文件,我得到了相同的错误,并且我在控制台中得到“Hello”。
To solve this issue, you just need to add external jar "appserv-rt.jar" in the buildpath of the client.
You can find it in the folder ...\glassfishv3\glassfish\lib
Or create a package with this jar and all its dependencies to add it in the BP
This is my code
Without the jar file, i got the same error and with I get "Hello" in the console.
从您设置的属性来看,这必须是一个独立的客户端。
确保将 gf-client.jar 包含到类路径中才能正常工作。 (glassfish\lib\gf-client.jar)
您也不需要设置您设置的属性。要指定服务器的非本地主机位置或您可能设置的替代端口:
您可能还想了解“如何从独立的 Java 客户端访问远程 EJB 组件?”在:
http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB
Judging from the properties you set this must be a standalone client.
Make sure you include the gf-client.jar to your classpath for this to work. (glassfish\lib\gf-client.jar)
You also don't need to set the properties you set. To specify a non-localhost location of your server or alternative port however you might set:
You also might want to go over "How do I access a Remote EJB component from a stand-alone java client?" at:
http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB
在我看来,您试图从未部署在处理连接池的服务器上的应用程序建立连接
Seems to me like your trying to establish a connection from an application that is not deployed on your server which handles the connnectionpool
我有类似的错误:
这是由
我的解决方案是添加包含实现 GlassFishORBHelper 接口的 GlassFishORBFactoryImpl.class 的 jar 引起的。
I had similar error:
which was caused by
My solution was to add jar that contains GlassFishORBFactoryImpl.class that implements the GlassFishORBHelper interface.