4 Replies Latest reply on Apr 23, 2004 1:12 AM by jonlee

    jdbc not bound

    rilux

      Hi,

      I've been hunting around for fixes for the "jdbc not bound" naming exception problem found when trying to create a datasource without any luck. It must be a configuration issue.

      I'm using a PostgreSQL database but cannot connect to it. I just get the "jbdc not bound" error message. My configuration files are below. Can anyone spot the problem.

      Cheers,

      Rilux
      postgres-service.xml
      <?xml version="1.0" encoding="UTF-8"?>

      <!-- $Id: postgres-ds.xml,v 1.1.2.1 2003/09/05 16:38:24 patriot1burke Exp $ -->

      <local-tx-datasource>
      <jndi-name>FooDS</jndi-name>
      <connection-url>jdbc:postgresql://localhost:5432/foo</connection-url>
      <driver-class>org.postgresql.Driver</driver-class>
      <user-name>foo</user-name>
      bar
      <!-- sql to call when connection is created
      <new-connection-sql>some arbitrary sql</new-connection-sql>
      -->

      <!-- sql to call on an existing pooled connection when it is obtained from pool
      <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
      -->

      </local-tx-datasource>



      ejb-jar.xml:
      <resource-ref >
      <res-ref-name>FooDS</res-ref-name>
      <res-jndi-name>java:/comp/env/jdbc/FooDS</res-jndi-name>
      <res-type>javax.sql.Datasource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      (this is at the start of the file. Should it be at the end?)

      jboss.xml:
      <resource-managers>
      <resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
      <res-name>FooDS</res-name>
      <res-jndi-name>java:/comp/env/jdbc/FooDS</res-jndi-name>
      </resource-manager>
      </resource-managers>

        • 1. Re: jdbc not bound
          sesques

          Why don't you try the simplest way:

          1) Copy the file postgres-ds.xml that you can find in docs/examples.jca into the deploy directory (and set the values according to your database).
          2) Configure your beans with the tag in jbosscmp-jdbc.xml
          3) reference the datasource with "java:/FooDS"

          • 2. Re: jdbc not bound
            rilux

            Ummm... if you have a look you'd notice that the postgres-service.xml I posted IS the example postgres-ds.xml with the relevant bits changed and some comments removed for brevity.

            Also, I should point out that I am avoiding entity beans in favour of DAOs and such don't have a jbosscmp-jdbc.xml file to use.

            In fact, I am using XDoclet to do the EJB and XML generation. There is a configuration option you can use to specify datasources but it doesn't appear to be working. I shall direct the question at the XDoclet mailing list.

            • 3. Re: jdbc not bound
              raja05

              Try something like this in ur ejb-jar.xml
              <resource-ref>
              <res-ref-name>jdbc/FooDS</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              <res-sharing-scope>Shareable</res-sharing-scope>
              </resource-ref>
              and in jboss.xml
              <resource-ref>
              <res-ref-name>jdbc/FooDS</res-ref-name>
              <jndi-name>Actual JNDI Name</jndi-name>
              </resource-ref>

              • 4. Re: jdbc not bound
                jonlee

                Try the following XDoclet snippet:

                * @ejb.resource-ref res-auth="Application"
                * res-name="jdbc/FooDS"
                * res-type="javax.sql.DataSource"
                * @jboss.resource-ref res-ref-name="jdbc/FooDS"
                * jndi-name="java:/FooDS"


                The JNDI binding for your datasource is "java:/FooDS" as given by the JNDI-name, "FooDS" in the datasource definition (*-ds.xml). The res-ref-name, "jdbc/FooDS" expands to the full reference "java:com/env/jdbc/FooDS".

                Hope that helps.