不可能在JBoss 6.1.0中注入JMS QueueConnectionFactory,并附带资源注释 [英] Impossible to inject JMS QueueConnectionFactory in JBoss 6.1.0 with resource annotation

查看:144
本文介绍了不可能在JBoss 6.1.0中注入JMS QueueConnectionFactory,并附带资源注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了很多时间来解决JBoss 6.1.0的问题,在我的会话bean中注入JMS连接工厂。我正在使用JBoss 6.1.0和默认配置文件,并在debian中运行。



我的代码是:

  @Resource(name =java:/ QueueConnectionFactory)
private QueueConnectionFactory factory

在jboss6 / server / default / deploy / hornetq / hornetq-jms.xml中有:

 < connection-factory name =QueueConnectionFactorysignature =queue> 
< xa> true< / xa>
<连接器>
< connector-ref connector-name =in-vm/>
< / connectors>
< entries>
< entry name =java:/ QueueConnectionFactory/>
< / entries>
< / connection-factory>

在部署我的耳机时,我收到此错误:


指定的映射名称/ lookup / jndi-name和任何ResourceProvider都不能处理名为env / java:/ QueueConnectionFactory的类型为javax.jms.QueueConnectionFactory的资源引用


尽管队列工厂在管理控制台中可见,它无法在我的会话bean中注入队列连接工厂。

解决方案

最后我找到了我的问题的答案:



@Resource 注释也需要使用真实的JNDI资源名称的 mappedName 属性。


I was spending a lot time to sort out problem with JBoss 6.1.0 to inject JMS connection factory in my session bean. I am using JBoss 6.1.0 with default profile and running it in debian.

Snip of my code are:

@Resource(name="java:/QueueConnectionFactory")
private QueueConnectionFactory factory

There is in jboss6/server/default/deploy/hornetq/hornetq-jms.xml:

<connection-factory name="QueueConnectionFactory" signature="queue">
        <xa>true</xa>
        <connectors>
           <connector-ref connector-name="in-vm"/>
        </connectors>
        <entries>
            <entry name="java:/QueueConnectionFactory"/>           
        </entries>
    </connection-factory>

While deploying my ear-file I am getting this error:

Neither any mapped-name/lookup/jndi-name specified nor any ResourceProvider could process resource-ref named env/java:/QueueConnectionFactory of type javax.jms.QueueConnectionFactory

It can't inject queue connection factory in my session bean despite of the queue factory being visible in the admin console.

解决方案

Finally I have found the answer to my question:

In the @Resource annotation the mappedName attribute with the real JNDI resource name is required as well.

这篇关于不可能在JBoss 6.1.0中注入JMS QueueConnectionFactory,并附带资源注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆