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

发布于 2024-08-02 08:31:42 字数 863 浏览 5 评论 0原文

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

有什么线索缺少什么吗?

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)

该 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>

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

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.

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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

|煩躁 2024-08-09 08:31:42

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

不允许:

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

允许:

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

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.

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>
喜你已久 2024-08-09 08:31:42

看来您没有

  • 将 OpenJMS 配置为使用 spring 正在查看的相同 JNDI 树 - 看看 此处
  • 查找 JNDI 中的错误路径。根据预感,从 jndiName 中删除“jms/”。

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.
時窥 2024-08-09 08:31:42

就我而言,我必须将资源(即 jms/XXX)从 tomcat 的 server.xml 移动到 context.xml,然后重新启动 tomcat 就可以了。

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.

唔猫 2024-08-09 08:31:42
    **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>
    **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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文