2 Replies Latest reply on Dec 5, 2017 8:03 AM by Nickolas Stojanovic

    Wildfly 11: Microsoft SQL Server driver incorrectly trys to connect to localhost

    Nickolas Stojanovic Newbie

      We want to switch from Wildfly 9 to Wildfly 11. We are using the Microsoft SQL Server driver in version 4.2. Unfortunately using the driver version 6.2. results in the same error.

       

      We use a Microsoft SQL Server and embed the driver like this:

       

      <driver name="sqljdbc" module="com.microsoft.sqlserver.jdbc">

          <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>

          <datasource-class>com.microsoft.sqlserver.jdbc.SQLServerDataSource</datasource-class>

      </driver>

       

      The data source is configured as the following:

       

      <datasource jndi-name="java:jboss/datasources/OurDbDS" pool-name="OurDbDS" enabled="true" use-java-context="true">

          <connection-url>jdbc:sqlserver://our.host.com:1433;DatabaseName=OurDb</connection-url>

          <driver>sqljdbc</driver>

          <pool>

              <min-pool-size>1</min-pool-size>

              <max-pool-size>4</max-pool-size>

          </pool>

          <security>

              <user-name>username</user-name>

              <password>password</password>

          </security>

          <validation>

              <check-valid-connection-sql>select 1</check-valid-connection-sql>

          </validation>

      </datasource>

       

      When deploying our application on Wildfly 9 everything works. When it is deployed on Wildfly 11 this error occurs:

       

      17:10:52,218 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 5) MSC000001: Failed to start service jboss.persistenceunit."some-company-util-app-our-app-auth-application-1.5.0-SNAPSHOT.war#our-app": org.jboss.msc.service.StartException in service jboss.persistenceunit."some-company-util-app-our-app-auth-application-1.5.0-SNAPSHOT.war#our-app": javax.persistence.PersistenceException: [PersistenceUnit: our-app] Unable to build Hibernate SessionFactory

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:195)

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:125)

          at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:640)

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:209)

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

          at java.lang.Thread.run(Thread.java:745)

          at org.jboss.threads.JBossThread.run(JBossThread.java:320)

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: our-app] Unable to build Hibernate SessionFactory

          at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:953)

          at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:883)

          at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)

          at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167)

          ... 7 more

      Caused by: org.hibernate.exception.GenericJDBCException: Unable to open JDBC Connection for DDL execution

          at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)

          at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

          at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

          at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:44)

          at org.hibernate.tool.schema.internal.Helper.buildDefaultDdlTransactionIsolator(Helper.java:145)

          at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:180)

          at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:59)

          at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:184)

          at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:65)

          at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:476)

          at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:422)

          at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:880)

          ... 9 more

      Caused by: java.sql.SQLException: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/OurDbDS

          at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:146)

          at org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64)

          at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)

          at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)

          at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:41)

          ... 17 more

      Caused by: javax.resource.ResourceException: IJ000453: Unable to get managed connection for java:jboss/datasources/OurDbDS

          at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:690)

          at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:430)

          at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:789)

          at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:138)

          ... 21 more

      Caused by: javax.resource.ResourceException: IJ031084: Unable to create connection

          at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:345)

          at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:352)

          at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:287)

          at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.createConnectionEventListener(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:1327)

          at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:499)

          at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:632)

          at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:604)

          at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:624)

          ... 24 more

      Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. 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:189)

          at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:240)

          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:1313)

          at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:995)

          at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:831)

          at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:627)

          at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(SQLServerDataSource.java:63)

          at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:314)

          ... 31 more

       

      Why does the driver want to connect to localhost although a connection-url is provided?