6 Replies Latest reply on Jun 3, 2013 9:53 AM by jesper.pedersen

    Setting datasource <driver/> in standalone.xml via system property

    wendyschmitz

      I have the following datasource configured in standalone.xml:

       

       

      <datasource jta="false" jndi-name="java:jboss/datasources/AEDS" pool-name="AEDS" enabled="true" use-ccm="false">
                <connection-url>${xdb.connection.url}</connection-url>
                <driver-class>${xdb.driver.class}</driver-class>
                <driver>${xdb.driver}</driver>
                ....
      </datasource>
      <drivers>
                <driver name="postgresql" module="postgresql">
                          <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                </driver>
                <driver name="sqlserver" module="com.microsoft.sqljdbc">
                           <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
                </driver>
      </drivers>
      

       

      I want to dynamically set the values for my datasource via a properties file, that I specify to JBoss via the -P parameter at startup:

       

      ./standalone.sh -P /path/to/properties/file
      

       

      For some reason, when I have the <driver/> element set via a property value like so:

      <driver>${xdb.driver}</driver>
      

       

      I get the following error in server.log and my datasource is not configured correctly.

       

      13:22:32,325 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
      JBAS014775:    New missing/unsatisfied dependencies:
            service jboss.jdbc-driver.${xdb_driver} (missing) dependents: [service jboss.data-source.java:jboss/datasources/AEDS]
      

       

      Testing the connection in the Admin console results in an error: BAS010440: failed to invoke operation: JBAS010442: failed to match pool. Check JndiName: java:jboss/datasources/AEDS

       

      When I replace ${xdb.driver} with the plain text value "postgresql" or "sqlserver", the datasource starts up correctly. How do I set the <driver/> element via my system property? I am using JBoss 7.1.1.Final.