javax.naming.NameNotFoundException: Name jms is not bound in this Context
我之前在win下使用activemq+tomcat的项目都没有问题,在linux下使用activemq发送短息时启动tomcat老是报错,网上找了好多方法试了好多遍都不行,后来还是综合在一起,也不知道怎么弄的就突然好了,1.将ActiveMQ lib目录下的5个jar包复制到Tomcat lib目录下:geronimo-j2ee-management_1.1_spec-1.0.1.
我之前在win下使用activemq+tomcat的项目都没有问题,在linux下使用activemq发送短息时启动tomcat老是报错,网上找了好多方法试了好多遍都不行,后来还是综合在一起,也不知道怎么弄的就突然好了,
1.将ActiveMQ lib目录下的5个jar包复制到Tomcat lib目录下:
geronimo-j2ee-management_1.1_spec-1.0.1.jar
geronimo-jms_1.1_spec-1.1.1.jar
geronimo-jta_1.0.1B_spec-1.0.1.jar
activemq-core-5.4.2.jar
activemq-web-5.4.2.jar
2.修改Tomcat的conf/context.xml文件:
本来项目里的META-INF文件夹下已经有了这个文件,但是网上说需要修改tomcat里的文件把,如下内容加入到context.xml里<Context></Context>
标签内
<Resource name="jms/FailoverConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="failover:(tcp://localhost:61616)?initialReconnectDelay=100&maxReconnectAttempts=5"
brokerName="localhost"
useEmbeddedBroker="false" />
<Resource name="jms/NormalConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://localhost:61616"
brokerName="localhost"
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/topic/SMS"
auth="Container"
type="org.apache.activemq.command.ActiveMQTopic"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="MY.TOPIC.SMS" />
<Resource name="jms/queue/MyQueue"
auth="Container"
type="org.apache.activemq.command.ActiveMQQueue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="MY.TEST.FOO.QUEUE" />
重启activemq,再重启tomcat,结果就好了,启动tomcat不报错了,短信也可以成功发送了
更多推荐
所有评论(0)