8 Replies Latest reply on Jul 19, 2011 10:15 AM by marcos_aps

    Problem configuring datasource in JBoss AS 7

    marcos_aps

      Hello, everybody!

       

      I'm having problems trying to configure a datasource in JBoss AS 7. I did this:

       

      1. Copied the JDBC driver file (postgresql-9.0-801.jdbc4.jar) to "JBOSS_HOME/standalone/deployments" directory.
      2. Added the following datasource element to the "JBOSS_HOME/standalone/configuration/standalone.xml" file:


      <datasource jndi-name="java:jboss/datasources/SCDH_DS" pool-name="SCDH_DS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
          <connection-url>
              jdbc:postgresql://localhost/solicitacoes
          </connection-url>
          <driver>
              org.postgresql.Driver
          </driver>
          <new-connection-sql>
              select 1
          </new-connection-sql>
          <security>
              <user-name>
                  user
              </user-name>
              <password>
                  password
              </password>
          </security>
          <validation>
              <check-valid-connection-sql>
                  select 1
              </check-valid-connection-sql>
              <validate-on-match>
                  false
              </validate-on-match>
              <background-validation>
                  false
              </background-validation>
              <useFastFail>
                  false
              </useFastFail>
          </validation>
      </datasource>

       

      Now, when I start the server I get these messages:

       

      08:01:43,390 INFO  [org.jboss.as.controller] (Controller Boot Thread) Service status report
         New missing/unsatisfied dependencies:
            service jboss.jdbc-driver.org_postgresql_Driver (missing)

       

      08:01:43,437 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "postgresql-9.0-801.jdbc4.jar"
      08:01:43,875 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.0)
      08:01:43,890 ERROR [org.jboss.as] (MSC service thread 1-1) JBoss AS 7.0.0.Final "Lightning" started (with errors) in 20765ms - Started 109 of 169 services (3 services failed or missing dependencies, 57 services are passive or on-demand)
      08:01:43,953 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "postgresql-9.0-801.jdbc4.jar"
      08:02:02,093 INFO  [org.jboss.as.osgi] (MSC service thread 1-1) Stopping OSGi Framework
      08:02:02,093 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) Unbound data source [java:jboss/datasources/SCDH_DS]

       

      I would like to know what I am missing or doing wrong.

       

      Thank you.

       

      Marcos

        • 1. Re: Problem configuring datasource in JBoss AS 7
          jaikiran

          Moved to AS7 user forum.

          • 2. Re: Problem configuring datasource in JBoss AS 7
            cgaffga

            I run into the same problem with mysql driver. Somehow the jar from deplayments directory gets deployed late or lazy, so I decided to create a module instead. That worked quite well and the error on startup was gone.

            Have a look here how to do it: http://community.jboss.org/wiki/DataSourceConfigurationInAS7#Installing_a_JDBC_driver_as_a_module

            or http://www.mastertheboss.com/jboss-application-server/308-jboss-as-7-introduction.html (Section: "Step #2: Install the driver")

             

            hope that helps

            • 3. Re: Problem configuring datasource in JBoss AS 7
              marcos_aps

              Hello, Christoph! Thank you for the answer.

               

              I'm almost sure that if I create a module, as you did, the problem will be solved. I just would like to make this work in the simplest way possible, I mean, by installing the JDBC driver as a deployment, not as a module, as the article pointed by you (which I already read) says it's possible. But unfortunatelly it seems that installing the JDBC driver as a deployment doesn't work as it should. Maybe I'll be forced to install it as a module.

               

              Marcos

              • 4. Re: Problem configuring datasource in JBoss AS 7
                maeste

                The problem is the <driver> tag. It have to point to driver name, that is in case of hot deployment the filename of deployed jar.

                For a complete description have a look here: http://www.javalinux.it/wordpress/2011/07/14/how-to-create-an-manage-datasources-in-as7/

                 

                regards

                S.

                • 5. Re: Problem configuring datasource in JBoss AS 7
                  cgaffga

                  hi Stefano,

                  hmm, good point. I also used some other driver name ("mysql-connector"), as I did not like the version number in the name. Maybe that's why it throw that error for me, too.

                  • 6. Re: Problem configuring datasource in JBoss AS 7
                    marcos_aps

                    Hello, Stefano.

                     

                    If I understand what you said, I changed the driver tag to this:

                     

                    <driver>

                        postgresql-9.0-801.jdbc4.jar

                    </driver>

                     

                    But I'm still getting the missing/unsatisfied dependencies message, although it says that the service was corrected:

                     

                    08:51:50,937 INFO [org.jboss.as.controller] (Controller Boot Thread) Service status report

                    New missing/unsatisfied dependencies:

                    service jboss.jdbc-driver.postgresql-9_0-801_jdbc4_jar (missing)

                     

                    08:51:50,953 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "postgresql-9.0-801.jdbc4.jar"

                    08:51:51,062 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.0)

                    08:51:51,062 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) Bound data source [java:jboss/datasources/SCDH_DS]

                    08:51:51,062 INFO [org.jboss.as] (MSC service thread 1-2) JBoss AS 7.0.0.Final "Lightning" started in 2266ms - Started 112 of 169 services (57 services are passive or on-demand)

                    08:51:51,093 INFO [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "postgresql-9.0-801.jdbc4.jar"

                    08:51:51,093 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) Service status report

                    Newly corrected services:

                    service jboss.jdbc-driver.postgresql-9_0-801_jdbc4_jar (now available)

                     

                    Marcos

                    • 7. Re: Problem configuring datasource in JBoss AS 7
                      maeste

                      Hi Marcus,

                       

                      log is saying that dependency has been corrected after jar deployment. It's correct and after last message your DS should work fine.

                       

                      Look at this log and my explanations:

                       

                      08:51:50,937 INFO [org.jboss.as.controller] (Controller Boot Thread) Service status report

                      New missing/unsatisfied dependencies:

                      service jboss.jdbc-driver.postgresql-9_0-801_jdbc4_jar (missing)

                       

                      I saying that jdbc driver isn't availabel during server startup and so the DS has a missing dependency. Then....

                      08:51:50,953 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "postgresql-9.0-801.jdbc4.jar"

                      08:51:51,062 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.0)

                      Here you have deployed the jar, or if the jar was already in place, server has reached the deploy phase for the jar.

                       

                      08:51:51,062 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) Bound data source [java:jboss/datasources/SCDH_DS]

                      Dependency are so fixed, and the DS can be bound

                      08:51:51,093 INFO [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "postgresql-9.0-801.jdbc4.jar"

                      08:51:51,093 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) Service status report

                      Newly corrected services:

                      service jboss.jdbc-driver.postgresql-9_0-801_jdbc4_jar (now available)

                      And the controlle tell you explicitly that the service previosly missing is now available.

                       

                       

                      hoping it helps

                      S.

                      • 8. Re: Problem configuring datasource in JBoss AS 7
                        marcos_aps

                        Yes, I saw the message saying that the service jboss.jdbc-driver.postgresql-9_0-801_jdbc4_jar is now available. I just got confused because I also saw the message "Newly corrected services". Well, if something was "corrected", I thought I was still doing something wrong or missing something for JBoss to have the need to correct something. But if JBoss display these messages for all JDBC drivers installed as a deployment ("missing" first and after that, "now available"), I think that there's no problem. Thank you, Stefano.

                         

                        Marcos