gpt4 book ai didi

java - 无法找到 JMS 聊天应用程序的 JNDI 资源

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:14:09 24 4
gpt4 key购买 nike

我正在尝试开发一个在 Glassfish 3 上运行的 JMS 应用程序。Eclipse Indigo 是我的 IDE。我试过运行 this example 。如果你觉得有必要,我会在这里复制代码。我不明白我应该用 JNDI 做什么。我已经通过管理控制台创建了两个具有确切指定名称的所需资源,但我得到了这个异常:

java.lang.RuntimeException: Orb initialization erorr
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:180)
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:411)
at Chat.<init>(Chat.java:38)
at Chat.main(Chat.java:113)
Caused by: java.lang.NullPointerException
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:152)
... 9 more
javax.naming.NamingException: Lookup failed for 'TopicConnectionFactory' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [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:411)
at Chat.<init>(Chat.java:38)
at Chat.main(Chat.java:113)
Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [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)
... 4 more
Caused by: java.lang.RuntimeException: Orb initialization erorr
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:180)
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)
... 5 more
Caused by: java.lang.NullPointerException
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:152)
... 9 more

据我所知,在服务器上,InitialContext 应该自动工作。

我做错了什么?

最佳答案

在构造 InitialContext 时,您需要提供一些描述如何从 JNDI 服务器访问和获取对象的属性。

主要是您需要提供一个标记供应商实现的属性和另一个指向数据存储位置的属性,并且您可能需要指定其他安全性或供应商特定属性。

对于您的情况(glassfish),我认为需要设置以下属性:

// the initial context factory, choosing the glassfish implementation
env.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
// glassfish's server location
env.setProperty("org.omg.CORBA.ORBInitialHost", "<host name or IP>");
env.setProperty("org.omg.CORBA.ORBInitialPort", "<port number>"); // default is 3700

关于java - 无法找到 JMS 聊天应用程序的 JNDI 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9556475/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com