我正在尝试将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 lib,并且openjms服务器正在运行。
答案 0 :(得分:4)
在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>
答案 1 :(得分:2)
好像你要么
答案 2 :(得分:0)
在我的情况下,我必须将资源,即jms / XXX从tomcat的server.xml移动到context.xml,然后重新启动tomcat就可以了。
答案 3 :(得分:0)
**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>