Exception stack is:
1. Connection refused: connect (java.net.ConnectException)
java.net.PlainSocketImpl:-2 (
http://java.sun.com/j2se/1.5.0/docs/api/java/net/ConnectException.html)
2. javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect] (javax.naming.ServiceUnavailableException) org.jnp.interfaces.NamingContext:248 (
http://java.sun.com/j2se/1.5.0/docs/api/javax/naming/ServiceUnavailableException.html)
3. javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]] (javax.naming.CommunicationException) org.jnp.interfaces.NamingContext:274 (
http://java.sun.com/j2se/1.5.0/docs/api/javax/naming/CommunicationException.html)
4. javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutExcept
ion: Receive timed out] [Root exception is javax.naming.CommunicationException:Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]] (javax.naming.CommunicationException) org.jnp.interfaces.NamingContext:1562 (
http://java.sun.com/j2se/1.5.0/docs/api
/javax/naming/CommunicationException.html)
5. Error creating bean with name 'jbossMQ' defined in URL [file:/C:/Mule/mule-2.1.1-SNAPSHOT/examples/hello/conf/hello-config.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException: Could not obtainconnection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]] (org.springframework.beans.factory.BeanCreationException) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory:1302 (null)
6. Error creating bean with name 'JMSConnector': Cannot resolve reference to bean 'jbossMQ' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbossMQ' defined in URL [file:/C:/Mule/mule-2.1.1-SNAPSHOT/examples/hello/conf/hello-config.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]] (org.springframework.beans.factory.BeanCreationException) org.springframework.beans.factory.support.BeanDefinitionValueResolver:275 (nul
l)
7. Initialisation Failure: Error creating bean with name 'JMSConnector': Cannotresolve reference to bean 'jbossMQ' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbossMQ' defined in URL [file:/C:/Mule/mule-2.1.1-SNAPSHOT/examples/hello/conf/hello-config.xml]: Invocation of init method failed; nested exception is javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error:javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception
is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]] (org.mule.api.lifecycle.InitialisationException) org.mule.registry.AbstractRegistry:79 (
http://www.mulesource.org/docs/site/cur
rent2/apidocs/org/mule/api/lifecycle/InitialisationException.html)
The explanation of this behavior is that org.springframework.jndi.JndiObjectFactoryBean does a one-off lookup of the JMS ConnectionFactory at startup. If this lookup fails (which it will if JBoss is offline), then no retry will happen because we haven't even reached that lifecycle phase yet (we're still in the Initialise phase).
I found
MULE-492which is for the exact same scenario and was apparently working for 1.x but since the way we use JNDI with JMS has changed for 2.x this is now a regression.There is a task pending for creating our own JNDI lookup class which supports retry strategies (MULE-3777). I think this is the ideal solution for this case, so I have made it a blocker for this issue.