使用HornetQ ConnectionFactory通过JNDI从EAR启动JBoss时出现NameNotFoundException [英] NameNotFoundException when starting JBoss with an EAR using HornetQ ConnectionFactory via JNDI

查看:184
本文介绍了使用HornetQ ConnectionFactory通过JNDI从EAR启动JBoss时出现NameNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试在JBoss 6.1上部署一个其中包含一些JMS MessageListener的应用程序. MessageListeners通过JNDI(使用Spring)获取连接工厂,我使用的是HornetQ默认连接工厂,其名称为ConnectionFactory.我目前仅使用JBoss开头的默认JMS Queues:DLQExpiryQueue

I am currently trying to deploy an app on JBoss 6.1 which has some JMS MessageListeners in it. The MessageListeners get the connection factory via JNDI (using Spring), I am using the HornetQ default connection factory which is named ConnectionFactory. I am currently just using the default JMS Queues that JBoss starts with: DLQ and ExpiryQueue

当我通过JMX进行部署时,应用程序启动没有问题.

When I deploy via JMX the app has no problem starting.

当我通过将应用程序复制到部署目录进行部署并启动服务器时,该应用程序将无法开始显示以下错误消息:javax.naming.NameNotFoundException: ConnectionFactory not bound.在我看来,这意味着该应用程序是在HornetQ启动之前启动的,可以通过JNDI进行访问.

When I deploy by copying the app in to the deploy directory and start the server the app will fail to start giving the following error message: javax.naming.NameNotFoundException: ConnectionFactory not bound. This implies to me that the app is starting before HornetQ starts and is available via JNDI.

我一直在尝试使用jboss-dependency.xml创建依赖关系,但是我无法使它正常工作,而且我不确定这是否是正确的方法.

I have looked in to creating dependencies using the jboss-dependency.xml however I have not been able to get this to work and I am not sure if this is even the correct approach.

如何确保HornetQ在我的应用程序之前启动?

How can I ensure that the HornetQ starts before my app?

推荐答案

昨天我刚遇到此问题,该问题是由JBoss在注册ConnectionFactory和Queues之前启动您的应用程序引起的.

I encountered just this problem yesterday, the problem is caused by JBoss starting your application before it has registered the ConnectionFactory and Queues.

我发现我的应用程序是从Eclipse完美部署的,它一直等到JBoss启动之后再部署.

I found my application deployed perfectly from Eclipse which waits until after JBoss has started before deploying.

解决方案是修改server/{node}/deploy/jbossweb.sar/META-INF/jboss-beans.xml文件,在WebServer bean中添加以下内容.

The solution is to modify the server/{node}/deploy/jbossweb.sar/META-INF/jboss-beans.xml file adding the following within the WebServer bean.

<depends>org.hornetq:module=JMS,name="NettyConnectionFactory",type=ConnectionFactory</depends>
<depends>org.hornetq:module=JMS,name="InVMConnectionFactory",type=ConnectionFactory</depends>  
<depends>org.hornetq:module=JMS,name="NettyThroughputConnectionFactory",type=ConnectionFactory</depends>

这对我有用,我在这里找到了解决方案: http ://edemmorny.com/2011/10/17/jboss-as-6-startup-connectionfactory-not-bound/

This worked for me and I found the solution here: http://edemmorny.com/2011/10/17/jboss-as-6-startup-connectionfactory-not-bound/

这篇关于使用HornetQ ConnectionFactory通过JNDI从EAR启动JBoss时出现NameNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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