4 Replies Latest reply on Oct 30, 2013 1:26 AM by perrfekto

    Difficulty in configuring PostgreSQL driver and datasources via the CLI

    perrfekto

      Hi,

      I am using JBoss AS 7.1.1 Final on a RedHat EL6 machine and am trying to register the PostgreSQL driver as well as the necessary datasources in jboss-cli but can't get it to work.

      Can you please assist.

       

      Done so far:

      • Added module.xml and the postgresql jar files to jboss-as-7.1.1.Final/modules/org/postgres/main

        The module.xml file content:

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

      <module xmlns="urn:jboss:module:1.0" name="org.postgresql">

        <resources>

          <resource-root path="postgresql-9.2-1003.jdbc4.jar"/>

        </resources>

        <dependencies>

          <module name="javax.api"/>

          <module name="javax.transaction.api"/>

        </dependencies>

      </module>

      • Tried to add the postgres driver by running jboss-cli.sh -c --file=configure-postgresql.cli

                configure-postgresql.cli content:

      # Batch script to add the PostgreSQL driver to the JBoss server configuration

      # Start batching commands

      batch

      # Add the  datasources subsystem

      /subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)

      # Run the batch commands

      run-batch

      # Reload the server configuration

      :reload

              

                This resulted in the following error:

      #1 /subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)
      Failed to execute batch: {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => "JBAS010441: Failed to load module for driver [org.postgresql]"}}

       

           However,

           If I add

      <driver name="postgresql" module="org.postgresql">

                          <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>

                     </driver>

           to standalone.xml, restart the server and then execute jboss-cli.sh -c --command=/subsystem=datasources/jdbc-driver=postgresql:read-resource, I get the following results

      {
          "outcome" => "success",
          "result" => {
              "driver-module-name" => "org.postgresql",
              "driver-name" => "postgresql",
              "driver-xa-datasource-class-name" => "org.postgresql.xa.PGXADataSource"
          }
      }

       

      • I kept the driver definition in standalone.xml and tried to create a datasource through CLI

      data-source add --name=ApplicationDS --driver-name=postgresql --connection-url=jdbc:postgresql://localhost/app --jndi-name=java:jboss/jdbc/ApplicationDS --user-name=app --password=whatever --use-ccm=false --max-pool-size=25 --blocking-timeout-wait-millis=5000

       

      This result in error:

                JBAS010468: Driver named "postgresql" is not installed.

       

      What do I need to do to configure the postgresql database driver and datasources via CLI?

       

      Thanks in advance.