我想在jBoss WildFly 8.2上用JMS做一些实验。
默认的WildFly standalone-full.xml配置文件包含以下片段:
<hornetq-server>
<connectors>
...
<in-vm-connector name="in-vm" server-id="0"/>
</connectors>
...
<jms-connection-factories>
<connection-factory name="InVmConnectionFactory">
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/ConnectionFactory"/>
</entries>
</connection-factory>
...
</jms-connection-factories>
<jms-destinations>
<!-- this destination I have added myself as I need a "topic", but
the default configuration has only two preconfigured "queues". -->
<jms-topic name="MyTestTopic">
<entry name="java:/jms/topic/MyTestTopic"/>
</jms-topic>
</jms-destinations>
</hornetq-server>我正在尝试通过以下方式将这个连接工厂和这个主题注入EJB:
@Stateless
public class JmsPublisher {
@Resource(mappedName = "java:/ConnectionFactory")
ConnectionFactory jmsConnectionFactory;
@Resource(mappedName = "java:/jms/topic/MyTestTopic")
Topic topic;但我在部署时收到以下错误消息:
Operation ("deploy") failed ... Services with missing/unavailable dependencies" => ...
...JmsPublisher\".jmsConnectionFactory is missing [jboss.naming.context.java.ConnectionFactory]"
...JmsPublisher\".topic is missing [jboss.naming.context.java.jms.topic.MyTestTopic]"我做错了什么?
发布于 2015-03-02 02:40:54
您应该使用mappedName注入目的地/连接工厂,并且可能需要考虑JMS2.0新APIs JMSContext
@Resource(mappedName = "java:/topic/someTopic")
private Topic topic;假设您有一个这样的条目
<jms-topic name="someTopic">
<entry name="topic/someTopic"/>
</jms-topic>对于连接工厂,建议使用默认的注入点
@Resource
private ConnectionFactory connectionFactory;但更好的是,只需使用@Inject JMSContext context并使用它发送消息。
发布于 2015-04-08 21:22:55
正如here所解释的,standalone.xml支持Java配置文件以及一些扩展,standalone-full.xml支持Java完整配置文件。
我的问题是我在standalone-full.xml中定义了JMS连接工厂和JMS主题。默认情况下,jBoss WildFly使用standalone.xml。
this question的答案解释了如何将WildFly配置为使用standalone-full.xml而不是standalone.xml。切换到standalone-full.xml解决了我的问题。
https://stackoverflow.com/questions/28797023
复制相似问题