Spring Application starting before its Datasource and Messaging dependencies in JBoss EAP 6 results in NameNotFoundException
Issue
- Our Spring Application is starting in parallel with some of the subsystems that the application has dependencies on. These subsystems are Messaging/HornetQ and the Datasource. When HornetQ and the Datasource start they register objects in JNDI for the destinations and the datasource we've defined. These destinations and datasource objects are required by our spring application to be available when it starts. In the logs, we can see that the JNDI names that the application fails to find are being registered after the application fails to load. How can we control the order of deployment for our application?
Caused by: javax.naming.NameNotFoundException: ConnectionFactory -- service jboss.naming.context.java.ConnectionFactory
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.lookup(InitialContext.java:120)
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(Unknown Source) [rt.jar:1.7.0_79]
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154) [spring-context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) [spring-context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) [spring-context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178) [spring-context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) [spring-context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105) [spring-context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:132) [spring-context-3.2.6.RELEASE.jar:3.2.6.RELEASE]
... 29 more
- During server startup camel component fails to connect to messaging subsystem hornetq with exception javax.naming.NameNotFoundException
Environment
Red Hat JBoss Enterprise Application Platform (EAP) 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.