繁体   English   中英

Wildfly 9 JMS注入未发生

[英]Wildfly 9 JMS injection not happening

以下类已部署在JBoss 9.02-final中,但注入的字段为null:

@ApplicationScoped
public class JMSEventPublisher implements IEventPublisherClient {

    @Inject
    private JMSContext context;

    @Resource (mappedName = "java:/jms/queue/Events")
    private Queue syncQueue;

我已经尝试使用@Stateless代替@ApplicationScoped ,我已经尝试使用lookup ,而不是mappedName ,但背景和syncQueue领域从不注入(所以我得到空指针异常,当我尝试发送JMS消息)。

战争开始后,JBoss日志中没有错误消息。 在JBoss启动时,这是与JMS相关的输出,在这里我们可以看到命名队列似乎已启动,而没有任何错误消息:

10:41:59,972 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 64) HQ221001: HornetQ Server version 2.4.7.Final (2.4.7.Final, 12
4) [34da3fdf-8dba-11e5-9213-51bb5b0e6fe5] 
10:42:00,399 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 64) WFLYMSG0002: Bound messaging object to jndi name java:jboss/ex
ported/jms/RemoteConnectionFactory
10:42:00,459 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 68) HQ221003: trying to deploy queue jms.queue.DLQ
10:42:00,471 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 69) WFLYMSG0002: Bound messaging object to jndi name java:/Connect
ionFactory
10:42:00,472 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 67) HQ221003: trying to deploy queue jms.queue.Events
10:42:00,476 INFO  [org.hornetq.core.server] (ServerService Thread Pool -- 66) HQ221003: trying to deploy queue jms.queue.ExpiryQueue
10:42:00,550 INFO  [org.jboss.as.connector.deployment] (MSC service thread 1-3) WFLYJCA0007: Registered connection factory java:/JmsXA
10:42:00,633 INFO  [org.hornetq.ra] (MSC service thread 1-3) HornetQ resource adaptor started
10:42:00,642 INFO  [org.jboss.as.connector.services.resourceadapters.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service 
thread 1-3) IJ020002: Deployed: file://RaActivatorhornetq-ra
10:42:00,647 INFO  [org.jboss.as.connector.deployment] (MSC service thread 1-3) WFLYJCA0002: Bound JCA ConnectionFactory [java:/JmsXA]
10:42:00,648 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) WFLYMSG0002: Bound messaging object to jndi name java:jboss/DefaultJMSC
onnectionFactory

知道为什么这种注射没有发生吗?

感谢@John Ament,他问了正确的问题。 我发现在我的工厂类中,引用是由new创建的,因此WELD没有进行注入。 问题解决了。

我删除了new JMSEventPublisher()而是添加@Inject在工厂类的字段(和BTW,我的工作版本JMSEventPublisher使用lookup ,而不是mappedName为资源查找syncQueue )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM