6 Replies Latest reply on Jul 7, 2016 6:31 AM by Vishak Ramanathan

    Issue while trying to deploy EAR in wildfly 10 :  Failed to connect to any server. Servers tried: [java:jboss/datasources/MSSQLServer (No connection provider for URI scheme "java" is installed)]

    Vishak Ramanathan Newbie

      Hi ,

      I am getting the following exception when one of the classes in the ear that is being deployed, tries to get Hibernate session factory. I would like to know where I am going wrong. Please see below the stack trace

      Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

              at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244)

              at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208)

              at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)

              at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)

              at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)

              at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)

              at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)

              at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)

              at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)

              at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)

              at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)

              at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)

              at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692)

              ... 151 more

      Caused by: org.hibernate.engine.jndi.JndiException: Unable to lookup JNDI name [java:jboss/datasources/MSSQLServer]

              at org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:100)

              at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:98)

              at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)

              at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)

              at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)

              at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)

              at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)

              at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)

              at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)

              at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)

              ... 163 more

      Caused by: javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [java:jboss/datasources/MSSQLServer (No connection provider for URI scheme "java" is installed)]

              at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)

              at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)

              at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)

              at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)

              at org.jboss.naming.remote.client.RemoteContext.lookupInternal(RemoteContext.java:104)

              at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:93)

              at javax.naming.InitialContext.lookup(Unknown Source)

              at javax.naming.InitialContext.lookup(Unknown Source)

              at org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:97)

              ... 172 more

       

      Thanks,

      Vishak

        • 2. Re: Issue while trying to deploy EAR in wildfly 10 :  Failed to connect to any server. Servers tried: [java:jboss/datasources/MSSQLServer (No connection provider for URI scheme "java" is installed)]
          Vishak Ramanathan Newbie

          Hi Jai

           

          Please find below the Standalone-full-ha.xml and Hibernate configurations

           

          Standalone-full-ha.xml

          =====================

          <subsystem xmlns="urn:jboss:domain:datasources:4.0">

                      <datasources>

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

                              <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>

                              <driver>h2</driver>

                              <security>

                                  <user-name>sa</user-name>

                                  <password>sa</password>

                              </security>

                          </datasource>

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

                              <connection-url>jdbc:sqlserver://MYIP:1433;DatabaseName=MYDB</connection-url>

                              <driver>sqlserver</driver>

                              <pool>

                                  <min-pool-size>50</min-pool-size>

                                  <max-pool-size>75</max-pool-size>

                              </pool>

                              <security>

                                  <user-name>dbusr</user-name>

                                  <password>usr#pwd</password>

                              </security>

                          </datasource>

                          <drivers>

                              <driver name="h2" module="com.h2database.h2">

                                  <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>

                              </driver>

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

                                  <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</xa-datasource-class>

                              </driver>

                          </drivers>

                      </datasources>

                  </subsystem>

           

          Hibernate Configurations

          ==========================

           

          <?xml version="1.0" encoding="UTF-8"?>

          <!DOCTYPE hibernate-configuration PUBLIC

            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

            "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

           

          <hibernate-configuration>

            <session-factory>

            <!-- Database connection settings -->

           

            <property name="hibernate.connection.datasource">java:jboss/datasources/MSSQLServer</property>

            <property name="connection.retrieveMessagesFromServerOnGetMessage">true</property>

            <property name="hibernate.jndi.url">java:jboss/datasources/MSSQLServer</property>

            <!-- JDBC connection pool (use the built-in) -->

            <property name="connection.pool_size">1</property>

           

            <!-- SQL dialect -->

            <property name="dialect">com.myapp.MySQLDialect</property>

           

            <!-- Enabling Container Managed Transaction -->

            <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>

            <property name="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform</property>

            <property name="hibernate.transaction.coordinator_class">jta</property>

            <property name="hibernate.ejb.interceptor">com.myapp.MyInterceptor</property>

            <property name="jta.UserTransaction">java:jboss/UserTransaction</property>

           

            <!-- Enable Hibernate's automatic session context management -->

            <property name="current_session_context_class">jta</property>

           

            <!-- Disable the second-level cache  -->

            <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

           

            <!-- Echo all executed SQL to stdout -->

            <property name="show_sql">false</property>

           

            <!-- Hibernate Isolation Level [READCOMMITED SNAPSHOT ISOLATION]-->

            <property name="connection.isolation">4096</property>

           

           

          and this how I try to get the Hibernate Session Factory

           

          Code snippet for getting Hibernate Session Factory

          ======================================

           

          Configuration cfg = new Configuration();

            cfg = cfg.configure(HIBERNATE_CFG_XML_FILE);

          String interceptorClassName ="com.myapp.MyInterceptor"

            if (interceptorClassName != null

            && !interceptorClassName.trim().equalsIgnoreCase("")) {

            cfg.setInterceptor((EmptyInterceptor) Class.forName(

            interceptorClassName.trim()).newInstance());

            }

           

            BootstrapServiceRegistry bootRegistry = new BootstrapServiceRegistryBuilder()

            .enableAutoClose().build();

            StandardServiceRegistryBuilder cfgRegistryBuilder = cfg

            .getStandardServiceRegistryBuilder();

            StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(

            bootRegistry, cfgRegistryBuilder.getAggregatedCfgXml())

            .applySettings(cfg.getProperties());

            ServiceRegistry serviceRegistry2 = registryBuilder.build();

           

            sessionFactory = cfg.buildSessionFactory(serviceRegistry2);

           

          Thanks...

          • 3. Re: Issue while trying to deploy EAR in wildfly 10 :  Failed to connect to any server. Servers tried: [java:jboss/datasources/MSSQLServer (No connection provider for URI scheme "java" is installed)]
            ehugonnet Apprentice

            You are defining the driver class as an XA datasource class

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

                 <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</xa-datasource-class>

            </driver>

            You should use:

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

                 <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>

            </driver>

            • 4. Re: Issue while trying to deploy EAR in wildfly 10 :  Failed to connect to any server. Servers tried: [java:jboss/datasources/MSSQLServer (No connection provider for URI scheme "java" is installed)]
              Vishak Ramanathan Newbie

              Hi.. I tried giving this

              <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>

              I am still getting the same error

              • 5. Re: Issue while trying to deploy EAR in wildfly 10 :  Failed to connect to any server. Servers tried: [java:jboss/datasources/MSSQLServer (No connection provider for URI scheme "java" is installed)]
                ehugonnet Apprentice

                Why are you using hibernate.jndi.url since all is local I guess ?

                Even if you want to use hibernate.jndi.url this is the URL to the JNDI provider not the JNDI URL.

                Remove this configuration param.

                • 6. Re: Issue while trying to deploy EAR in wildfly 10 :  Failed to connect to any server. Servers tried: [java:jboss/datasources/MSSQLServer (No connection provider for URI scheme "java" is installed)]
                  Vishak Ramanathan Newbie

                  If I remove the JNDI URL .. I am getting the following error

                   

                  Caused by: org.hibernate.engine.jndi.JndiException: Unable to open InitialContext

                          at org.hibernate.engine.jndi.internal.JndiServiceImpl.buildInitialContext(JndiServiceImpl.java:112)

                          at org.hibernate.engine.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:94)

                          at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:98)

                          at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)

                          at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217)

                          at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189)

                          at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145)

                          at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66)

                          at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)

                          at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)

                          at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:234)

                          ... 186 more

                  Caused by: javax.naming.NamingException: No provider URL configured for connection

                          at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateCachedNamingStore(InitialContextFactory.java:196)

                          at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:171)

                          at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:146)

                          at org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:114)

                          at org.jboss.as.naming.InitialContext.init(InitialContext.java:99)

                          at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)

                          at org.jboss.as.naming.InitialContext.<init>(InitialContext.java:89)

                          at org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:43)

                          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)

                          at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)

                          at javax.naming.InitialContext.init(InitialContext.java:244)

                          at javax.naming.InitialContext.<init>(InitialContext.java:192)

                          at org.hibernate.engine.jndi.internal.JndiServiceImpl.buildInitialContext(JndiServiceImpl.java:109)

                          ... 196 more