1 Reply Latest reply on Nov 11, 2012 4:55 PM by nickarls

    Does the xa-datasource-class element actually do anything?

    twic

      I am setting up an application with a JDBC driver packaged as a module. A simple example of this is at https://bitbucket.org/twic/drivermodule. Here is the datasources subsystem from standalone.xml:

       

      <subsystem xmlns="urn:jboss:domain:datasources:1.0">
          <datasources>
              <datasource jndi-name="java:/jdbc/demoDS" pool-name="demoDS" enabled="true" use-java-context="true">
                  <connection-url>jdbc:postgresql://127.0.0.1/demo</connection-url>
                  <driver>pg</driver>
                  <security>
                      <user-name>demo</user-name>
                      <password>demo</password>
                  </security>
                  <validation>
                      <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker" />
                      <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter" />
                  </validation>
                  <statement>
                      <track-statements>TRUE</track-statements>
                  </statement>
              </datasource>
      
              <drivers>
                  <driver name="h2" module="com.h2database.h2">
                      <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                  </driver>
                  <driver name="pg" module="org.postgresql.jdbc">
                      <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                  </driver>
              </drivers>
          </datasources>
      </subsystem>
      

       

      And here is the module.xml for the driver:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="org.postgresql.jdbc">
      
          <resources>
              <resource-root path="postgresql-9.1-901-1.jdbc4.jar"/>
          </resources>
      
          <dependencies>
              <module name="javax.api" />
              <module name="javax.transaction.api" />
          </dependencies>
      
      </module>
      

       

      The good news is that this works fine. My application starts, and connects to the database.

       

      As an experiment, i changed the content of the xa-datasource-class element in the PostgreSQL driver definition to be nonsense.

       

      My application still starts, and connects to the database.

       

      I removed the xa-datasource-class element altogether; the driver element was then empty.

       

      My application still starts, and connects to the database.

       

      What is going on? Does JBoss actually look at the xa-datasource-class element at all? How is it determining the driver or datasource class?

       

      I haven't set the services attribute on my module definition, and according to the module descriptor documentation at https://docs.jboss.org/author/display/MODULES/Module+descriptor, that means that no services defined in the JARs should be exported. So, if that is correct, JBoss can't be determining the driver based on the java.sql.Driver service definition.

       

      Again, what is going on?