eclipse glassfish 3,客户端错误

发布于 2024-11-07 07:18:50 字数 4231 浏览 2 评论 0原文

我正在使用最新的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

泪是无色的血 2024-11-14 07:18:50

要解决这个问题,只需在客户端的buildpath中添加外部jar“appserv-rt.jar”即可。

您可以在文件夹 ...\glassfishv3\glassfish\lib 中找到它

,或者使用此 jar 及其所有依赖项创建一个包,以将其添加到 BP

这是我的代码

InitialContext ctx = new InitialContext();
HelloWorld helloWorldRemote = (HelloWorld) ctx.lookup("ejb/helloWorldBeanJndiName");
System.out.println(helloWorldRemote.sayHello());

没有 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

InitialContext ctx = new InitialContext();
HelloWorld helloWorldRemote = (HelloWorld) ctx.lookup("ejb/helloWorldBeanJndiName");
System.out.println(helloWorldRemote.sayHello());

Without the jar file, i got the same error and with I get "Hello" in the console.

何以心动 2024-11-14 07:18:50

从您设置的属性来看,这必须是一个独立的客户端。

确保将 gf-client.jar 包含到类路径中才能正常工作。 (glassfish\lib\gf-client.jar)

您也不需要设置您设置的属性。要指定服务器的非本地主机位置或您可能设置的替代端口:

prop.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
prop.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

您可能还想了解“如何从独立的 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:

prop.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
prop.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

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

如若梦似彩虹 2024-11-14 07:18:50

在我看来,您试图从未部署在处理连接池的服务器上的应用程序建立连接

Seems to me like your trying to establish a connection from an application that is not deployed on your server which handles the connnectionpool

み零 2024-11-14 07:18:50

我有类似的错误:

java.lang.RuntimeException: Orb initialization erorr at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:180)

这是由

java.lang.NullPointerException at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:152)

我的解决方案是添加包含实现 GlassFishORBHelper 接口的 GlassFishORBFactoryImpl.class 的 jar 引起的。

I had similar error:

java.lang.RuntimeException: Orb initialization erorr at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:180)

which was caused by

java.lang.NullPointerException at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:152)

My solution was to add jar that contains GlassFishORBFactoryImpl.class that implements the GlassFishORBHelper interface.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文