7 Replies Latest reply on Jul 23, 2012 11:45 AM by Neven Cvetković

    JBoss 7.1.1 won't deploy PostgreSQL driver

    Johannes Degler Newbie

      Hi,

       

      I'm currently trying to set up a PostgreSQL data source. I've read the documentation and various How-Tos but for some reason I can't get it to work.

       

      First I've installed the driver as a module in org/postgresql/main. The module.xml looks like this:

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

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

         <!-- Install with jboss-cli command

           jboss-cli.sh --connect command="/subsystem=datasources/jdbc-driver=postgresql-driver:add(driver-name=postgresql-driver, driver-class-name=org.postgresql.Driver, driver-module-name=org.postgresql"

         -->

         <resources>

            <resource-root path="postgresql-9.1-902.jdbc4.jar"/>

         </resources>

         <dependencies>

            <module name="javax.api"/>

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

         </dependencies>

      </module>

       

      I installed the module using the JBoss CLI: jboss-cli.bat --connect command="/subsystem=datasources/jdbc-driver=postgresql-driver:add(driver-name=postgresql-driver, driver-class-name=org.postgresql.Driver, driver-module-name=org.postgresql"

       

      It automatically added a driver definition to my standalone.xml:

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

         <driver-class>org.postgresql.Driver</driver-class>

      </driver>

       

       

      But when starting JBoss the log never mentions deploying the driver. It does however deploy the H2 driver wich was already declared in the standalone.xml file.

       

      I tried adding a datasource defintion to standalone.xml using the postgres driver, but this only causes JBoss to log an error:

      JBAS014775:    New missing/unsatisfied dependencies:       service jboss.jdbc-driver.postgresql (missing) dependents: [service jboss.data-source.java:jboss/datasources/PrototypeDS]

       

      My datasource looks like this:

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

        <connection-url>jdbc:postgresql:mdsdprototype</connection-url>

        <driver>postgresql-driver</driver>

        <security>

          <user-name>mdsd</user-name>

          <password>mdsd</password>

        </security>

      </datasource>

       

      Any idea what I'm doing wrong?

        • 1. Re: JBoss 7.1.1 won't deploy PostgreSQL driver
          Neven Cvetković Newbie

          Johannes,

           

          You could develop a simple application (WAR or EAR) with WEB-INF(META-INF)/jboss-deployment-structure.xml that references that org.postgresql module, e.g.

           

              <dependencies>

                <module name="org.postgresql" slot="main"/>

              </dependencies>

           

          At least, you will see if the drivers are loaded properly....

           

          (edited: I attached test-postgresql.war file you can deploy... see WEB-INF/jboss-deployment-structure.xml how I made my WAR dependent on "org.postgresql" module)

          • 2. Re: JBoss 7.1.1 won't deploy PostgreSQL driver
            Juan Burgos Newbie

            1. module.xml in modules/org/postgresql/main

             

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

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

               <resources>

                  <resource-root path="postgresql-9.1-901.jdbc4.jar"/>

               </resources>

               <dependencies>

                  <module name="javax.api"/>

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

               </dependencies>

            </module>

             

            2. Datasource in standalone.xml

            <datasources>

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

                                <connection-url>jdbc:postgresql://localhost:5432/postgresDatabase</connection-url>

                                <driver>postgresql</driver>

                                <pool>

                                    <min-pool-size>1</min-pool-size>

                                    <max-pool-size>4</max-pool-size>

                                    <prefill>false</prefill>

                                    <use-strict-min>false</use-strict-min>

                                    <flush-strategy>FailingConnectionOnly</flush-strategy>

                                </pool>

                                <security>

                                    <user-name>userPostgres</user-name>

                                    <password>passwordUserPostgres</password>

                                </security>

                           </datasource>

                           <drivers>

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

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

                                </driver>

                           </drivers>

            </datasources>

            • 3. Re: JBoss 7.1.1 won't deploy PostgreSQL driver
              Wolf-Dieter Fink Master

              If you install the modul correct and add the driver section to the datasource subsystem you should see a log message like

                   JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.0)

               

              The module.xml and the driver must located in the .../main directory

              • 4. Re: JBoss 7.1.1 won't deploy PostgreSQL driver
                Johannes Degler Newbie

                I added the jboss-deployment-structure.xml to the existing project and it works fine now. At least as long as I add the datasource to standalone.xml, using a -ds.xml file doesn't work.

                • 5. Re: JBoss 7.1.1 won't deploy PostgreSQL driver
                  Neven Cvetković Newbie

                  Can you post (attach) your *-ds.xml file here?    

                  • 6. Re: JBoss 7.1.1 won't deploy PostgreSQL driver
                    Johannes Degler Newbie

                    Sure, but it's the same configuration used in standalone.xml.

                    • 7. Re: JBoss 7.1.1 won't deploy PostgreSQL driver
                      Neven Cvetković Newbie

                      Hmmm... it looks all right.

                       

                      Try to play with "deployed"

                       

                      1) Remove <datasource>....</datasource> from standalone.xml

                      2) Remove <driver>postgresql-driver</driver> from standalone.xml

                      3) Deploy "postgresql-9.1-901.jdbc4.jar" to $JBOSS_HOME/standalone/deployments directory

                      4) Update prototype-pg-ds.xml with new driver, e.g.

                       

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

                      <datasources>

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

                                          <connection-url>jdbc:postgresql:mdsdprototype</connection-url>

                        <driver>postgresql-9.1-901.jdbc4.jar</driver>

                          <security>

                            <user-name>test</user-name>

                            <password>test</password>

                          </security>

                                </datasource>

                      </datasources>

                       

                      5) Deploy updated prototype-pg-ds.xml

                       

                      That should deploy the datasource and use the deployed drivers. Try playing with undeploying the drivers (e.g. rm postgresql-9.1.-901.jdbc4.jar.deployed) and see how that affects the datasource...