问题
I'm trying to deploy an application (EAR) which has Spring JMS listeners, BlazeDS flex and HornetQ in Jboss EAP 6.2.4. When I deploy the application and try to start the server, I'm getting the below exception.
Caused by: javax.naming.NameNotFoundException: JmsXA -- service jboss.naming.context.java.JmsXA
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:103)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)
at org.jboss.as.naming.InitialContext$DefaultInitialContext.lookup(InitialContext.java:241)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:183)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_80]
at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_80]
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154) [spring-context-3.0.7.RELEASE.jar:3.0.7.RELEASE]
I saw this thread with similar problem (https://stackoverflow.com/a/12278834/1326592) but this wouldn't work in my case as I dont have a SAR file in my application.
I'm looking up to the Queues and ConnectionFactory via jee
<jee:jndi-lookup id="connectionFactory" jndi-name="java:/JmsXA"/>
<jee:jndi-lookup id="RequestsQueue" jndi-name="java:/jms/queue/requestQueue"/>
Please suggest a solution of how to start the HornetQ in Jboss before deploying my application.
回答1:
I found a solution for the above issue.
This got resolved after referring to the JNDI's via resource-ref in web.xml
<resource-ref id="ItftRequestsQueue">
<res-ref-name>requestQueue</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<lookup-name>java:/jms/queue/requestQueue</lookup-name>
</resource-ref>
and referring to the resource-ref in my spring.xml as
<jee:jndi-lookup id="connectionFactory" jndi-name="connectionFactory"/>
<jee:jndi-lookup id="requestsQueue" jndi-name="requestQueue"/>
来源:https://stackoverflow.com/questions/33387127/namenotfoundexception-when-starting-jboss-with-an-ear-using-hornetq-connectionfa