【问题标题】:JMS queue connection factory in strutsstruts中的JMS队列连接工厂
【发布时间】:2011-11-19 07:42:03
【问题描述】:

我正在尝试将 JMS 消息发送器集成到基于 struts 的 Web 应用程序中。我在一个方法中定义了消息发送者,并在actionForm的execute方法中调用了该方法。我得到的错误是

javax.naming.NameNotFoundException: Name queueConnectionFactory is not bound in this Context

我猜错误在这个地方

 try {
    connectionFactory = (ConnectionFactory)jndiContext.lookup("queueConnectionFactory");
    destination = (Destination)jndiContext.lookup(destinationName);
} catch (NamingException e) {
    e.printStackTrace();
    System.exit(1);
}

我正在使用 ActiveMQ 作为消息代理。

【问题讨论】:

  • 关于应用程序的另一件事是,执行后tomcat自动关闭,我在网页上收到错误,即无法连接......

标签: tomcat struts jms activemq


【解决方案1】:

在 web 层中,您必须使用 conn 的完整 JNDI 名称。工厂,即java:comp/env/queueConnectionFactory

在Tomcat中,还需要在web.xml中声明:

<resource-ref id="ResourceRef_0">
   <description>Logical mapping of QueueConnectionFactory</description>
   <res-ref-name>queueConnectionFactory</res-ref-name>
   <res-type>javax.jms.QueueConnectionFactory</res-type>
   <res-auth>Container</res-auth>
   <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

【讨论】:

    猜你喜欢
    • 2017-03-13
    • 1970-01-01
    • 1970-01-01
    • 2021-05-10
    • 1970-01-01
    • 2014-07-03
    • 2019-05-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多