java JNDI 上下文 :: 在此上下文中未绑定的名称 jms

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1293453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 15:59:43  来源:igfitidea点击:

JNDI Context :: Name jms not bound in this Context

javaspringjmsopenjms

提问by lud0h

I am trying to configure a JMS server (OpenJMS) into a Spring application and when I refer the resources using the notation "jms/<> I get a "name" not bound exception.

我正在尝试将 JMS 服务器 (OpenJMS) 配置到 Spring 应用程序中,当我使用符号“jms/<>”引用资源时,我得到一个“名称”未绑定异常。

Any clue what is missing?

任何线索丢失了什么?

javax.naming.NameNotFoundException: Name jms is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:768)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:138)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:779)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:138)

The bean is defined as:

bean 定义为:

<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="jmsProvider"/>
    <property name="jndiName" value="jms/RefreshTopic_CF"/>
    <property name="resourceRef" value="true" />
</bean>

I have the JMS lib in class path and the openjms server is running.

我在类路径中有 JMS 库,并且 openjms 服务器正在运行。

回答by lud0h

In the web.xml we couldn't refer the as an interface (javax.jms.Topic) we had to use the exact class. This was a problem with OpenJMS and not with Websphere.

在 web.xml 中,我们不能将其作为接口 (javax.jms.Topic) 引用,我们必须使用确切的类。这是 OpenJMS 的问题,而不是 Websphere 的问题。

Not allowed:

不允许:

<resource-ref id="ResourceRef_125180">
    <description>Topic</description>
    <res-ref-name>jms/MyTopic</res-ref-name>

    <res-type>javax.jms.Topic</res-type>

    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>        
</resource-ref>

allowed:

允许:

<resource-ref id="ResourceRef_125180">
    <description>Topic</description>
    <res-ref-name>jms/MyTopic</res-ref-name>

    <res-type>org.exolab.jms.client.JmsTopic</res-type>

    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>        
</resource-ref>

回答by David Rabinowitz

It seems you either

看来你要么

  • Didn't configured the OpenJMS to use the same JNDI tree the spring is looking at - have a look here
  • Looking for the wrong path in the JNDI. As a hunch, drop the "jms/" from the jndiName.
  • 没有将 OpenJMS 配置为使用 spring 正在查看的相同 JNDI 树 - 看看这里
  • 在 JNDI 中寻找错误的路径。凭直觉,从 jndiName 中删除“jms/”。

回答by Sahil

In my case I had to move the resource i.e jms/XXX from server.xml of tomcat to context.xml and then restarting the tomcat did the trick.

在我的情况下,我不得不将资源即 jms/XXX 从 tomcat 的 server.xml 移动到 context.xml,然后重新启动 tomcat 就可以了。

回答by yasin

    **Create the file <webapp-root>/META-INF/context.xml**. 
here`Here is an example:
    <Context antiJARLocking="true">
        <Resource
            name="jms/ConnectionFactory"
            auth="Container"
            type="org.apache.activemq.ActiveMQConnectionFactory"
            description="JMS Connection Factory"
            factory="org.apache.activemq.jndi.JNDIReferenceFactory"
            brokerURL="tcp://localhost:61616"
            brokerName="LocalActiveMQBroker"
            useEmbeddedBroker="false"/>

        <Resource name="jms/topic/MyTopic"
            auth="Container"
            type="org.apache.activemq.command.ActiveMQTopic"
            factory="org.apache.activemq.jndi.JNDIReferenceFactory"
            physicalName="MY.TEST.FOO"/>
        <Resource name="jms/queue/MyQueue"
            auth="Container"
            type="org.apache.activemq.command.ActiveMQQueue"
            factory="org.apache.activemq.jndi.JNDIReferenceFactory"
            physicalName="MY.TEST.FOO.QUEUE"/>
    </Context>