NameNotFoundException when starting JBoss with an

2019-07-29 06:51发布

问题:

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

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

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.

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.

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

回答1:

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

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

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>

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