Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-14025

Unable to remove the default datasource binding from the ee subsystem

    Details

    • Steps to Reproduce:
      Hide

      Remove the datasource from the ee subsystem default bindings such that it is:

               <default-bindings context-service="java:jboss/ee/concurrency/context/default" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/> 

         Deploy reproducer2.war and start JBoss

      ------

      Add a 2nd datasource to make sure the correct datasource is used:

                      <datasource jndi-name="java:jboss/datasources/AppDS" pool-name="AppDS" enabled="true" use-java-context="true">
                          <connection-url>jdbc:h2:mem:test2;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> 
      Show
      Remove the datasource from the ee subsystem default bindings such that it is:         < default -bindings context-service= "java:jboss/ee/concurrency/context/ default " managed-executor-service= "java:jboss/ee/concurrency/executor/ default " managed-scheduled-executor-service= "java:jboss/ee/concurrency/scheduler/ default " managed-thread-factory= "java:jboss/ee/concurrency/factory/ default " />    Deploy reproducer2.war and start JBoss ------ Add a 2nd datasource to make sure the correct datasource is used:                 <datasource jndi-name= "java:jboss/datasources/AppDS" pool-name= "AppDS" enabled= " true " use-java-context= " true " >                     <connection-url>jdbc:h2:mem:test2;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>
    • Workaround Description:
      Hide

      Workaround, specify a default binding for the datasource such that the datasource is defined in the datasources subsystem:

               <default-bindings datasource="java:jboss/datasources/MyDataSource" /> 

         

      Show
      Workaround, specify a default binding for the datasource such that the datasource is defined in the datasources subsystem:         < default -bindings datasource= "java:jboss/datasources/MyDataSource" />    

      Description

      EAP 7.2+ is creating a dependency on the DefaultDataSource when it should not.

      If the default datasource is removed from the ee subsystem and an application is deployed with a class that has @Resource specifying a name to inject which is not linked to the default datasource, it should NOT fail with a missing dependency.

      This was found with a Spring application, where Spring configuration is defining java:comp/env/dataSource to link to the real datasource.  In EAP 7.1 the application deployed with no issue, in EAP 7.2+ JBoss is failing the deployment due to the datasource=... being removed from the default bindings in the ee subsystem.

       

        @Resource(name = "dataSource")
        private DataSource dataSource; 

       

       18:08:15,547 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "reproducer2.war")]) - failure description: {
          "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.module.reproducer2.reproducer2.DefaultDataSource"],
          "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.reproducer2.reproducer2.env.non-existant is missing [jboss.naming.context.java.module.reproducer2.reproducer2.DefaultDataSource]"]
      }

        Gliffy Diagrams

          Attachments

          1. reproducer2.war
            2 kB
          2. reproducer-spring.war
            3.92 MB
          3. reproducer-spring2.war
            3.92 MB
          4. standalone.xml
            28 kB

            Issue Links

              Activity

                People

                • Assignee:
                  gaol Lin Gao
                  Reporter:
                  gaol Lin Gao
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated: