Unable to get managed connection for java:jboss……

VMs are not able to connect to SQL Azure Server. Ping to the SQL server is also not resolving to any IP. I also observe that the VMs are not able to connect to services running on other VM within the same cloud service.

Error:
ERROR:

ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/saoDataSource
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-3.1.2.RELEASE.jar:3.1.2.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:733) [spring-context-3.1.2.RELEASE.jar:3.1.2.RELEASE]
..
..
..
..
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host tiuexjq7la.database.windows.net, port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
        at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)
        at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)
        at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
        at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:254)

Troubleshooting:
Unable to ping the server at XXXXXX.database.windows.net. Able to ping from local server but unable to connect from this particular VM which has the issue.

UDL connecting fine from the other client but fails from the VM on azure.

ipconfig /registerdns -- Same issue

The pointer came from the fact that we were unable to browse to websites from this particular Virtual Machine.

Internet options, everything looked fine. Proxy and other connection related settings were in place.

nslookup was erroring:

C:\Users\xxxxxxx>nslookup
DNS request timed out.
    timeout was 2 seconds.
Default Server:  UnKnown
Address:  xx.xxx.xx.xxx

> xxxxxxx.com
Server:  UnKnown
Address:  xx.xxx.xx.xxx

DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
*** Request to UnKnown timed-out
> xxxxxxx.com
C:\Users\saoadmin>

It was a custom DNS server.
On further probing, the custom DNS server wasn't configured properly and also it was not in use.

So we deleted the DNS server and rebooted the VMs in question.

After reboot, nslookup was working fine.

SQL Connectivity came back up and were able to browse to websites.

So in conclusion, when you see the above error as mentioned in the stack, there is nothing to check from SQL Server side or from the port 1433 perspective.

Reviewed By: Lalitesh Kumar