3 Replies Latest reply on Jun 3, 2003 8:23 AM by Jon Martin Solaas

    Using default datasource in standardjbosscmp-jdbc.xml

    jbrosenberg Newbie

      I'm just getting started with using jBoss 3.2.1...

      I read about the standardjbosscmp-jdbc.xml file
      in the /jboss-home/server/default/conf directory....

      I expected settings there to be inherited by the
      ejb's I deploy, etc....

      So, I set in the defaults section in
      standardjboss-cmp.xml to have my
      OracleDS as the default:


      java:/OraclePool
      <datasource-mapping>Oracle8</datasource-mapping>

      .....

      And, I deployed the oracle-ds.xml datasource, which looks like this:


      <local-tx-datasource>
      <jndi-name>OracleDS</jndi-name>
      <connection-url>jdbc:oracle:thin:@.....</connection-url>
      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
      <user-name>.....</user-name>
      ......
      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
      </local-tx-datasource>



      I also removed the Hypersonic DefaultDS from the deploy dir....

      Then I created a simple EJB, and I left the defaults section empty in the jbosscmp-jdbc.xml for the ejb, hoping that it would just use the default OracleDS defined in standardjbosscmp-jdbc.xml....

      But it failed to deploy, complaining that it couldn't find DefaultDS.....

      I tried putting the Hypersonic - DefaultDS back, and then the ejb deployed fine, using Hypersonic and not Oracle....

      Is there something I am not understanding about the behavior of the standardjbosscmp-jdbc.xml file?

      Thanks,

      Jason

        • 1. Re: Using default datasource in standardjbosscmp-jdbc.xml
          jbrosenberg Newbie

          Sorry, there's a typo....
          I did define the default
          ds to be:

          java:/OracleDS

          (Not OraclePool as I typed there)....

          Jason

          • 2. Re: Using default datasource in standardjbosscmp-jdbc.xml
            Jon Martin Solaas Newbie

            What happens in the jboss console window (or logs) when you (re)deploy your oracle-ds.xml? Do you get exceptions or happygolucky-messages?

            Are you sure your jbosscmp-jdbc.xml is actually seen by jboss? Sounds like it's being ignored. Try to make it unparsable, and redeploy, just to check if jboss actually tries to read it.

            • 3. Re: Using default datasource in standardjbosscmp-jdbc.xml
              Jon Martin Solaas Newbie

              Uh, sorry, I didn't notice you altered the standardjboss-cmp-file instead of telling jboss which datasource to use in jbosscmp-jdbc.xml.

              Here is what I would do:

              1. restore the original hypersonic-ds.xml and the original standardjbosscmp-jdbc.xml, just to make sure there are no typo's lurking around. (By default JMS uses DefaultDS for message queues it seems, and it might or might not work well with Oracle and defaults. Anyway, this shouldn't affect your entitybeans. However you should have seen a lot of complaints from jboss when the DefaultDS was gone when you removed hypersonic-ds.xml ... )

              2. (re)deploy oracle-ds.xml and carefully watch your logs to see if OracleDS is actually registered, or if you get any exceptions. Does it find the driver classes? Did you put the driver jar in .../server/default/lib where it'll be read (you must restart jboss otherwise it won't find it, I think ...)

              3. in order to make your entity-beans use OracleDS instead of DefaultDS you must add something to your jbosscmp-jdbc.xml that you include in your ejb jar file.

              I just used the standardjbosscmp-jdbc.xml as a template and ripped out basically everything except the -section. I also kept the relevant type-mapping to tinker with, but I suppose you don't need that.

              This leaves me with DefaultDS on hypersoniq that at least keep JMS - and what do I know else - happy, and MyVeryOwnDS that is defined in my myveryown-ds.xml and ofcourse ejb-specific instructions on which datasource to use.

              Here is the top of my jbosscmp-jdbc.xml (which goes in meta-inf, ofcourse)

              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE jbosscmp-jdbc>

              <!-- ===================================================================== -->
              <!-- -->
              <!-- Standard JBossCMP-JDBC Configuration -->
              <!-- -->
              <!-- ===================================================================== -->

              <!-- $Id: standardjbosscmp-jdbc.xml,v 1.23.2.25 2003/01/27 22:29:13 binaryfeed Exp $ -->

              <jbosscmp-jdbc>


              java:/AprosjektDS
              <datasource-mapping>mySQL</datasource-mapping>

              <create-table>true</create-table>
              <remove-table>false</remove-table>
              <read-only>false</read-only>
              <time-out>300</time-out>
              <pk-constraint>true</pk-constraint>
              <fk-constraint>false</fk-constraint>
              <row-locking>false</row-locking>
              <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
              <read-ahead>
              on-load
              <page-size>1000</page-size>
              <eager-load-group>*</eager-load-group>
              </read-ahead>
              <list-cache-max>1000</list-cache-max>


              <type-mappings>

              <type-mapping>
              mySQL
              <row-locking-template>SELECT ?1 FROM ?2 WHERE ?3 FOR UPDATE</row-locking-template>
              <pk-constraint-template>CONST


              .......

              Using jboss 3.0.X I used to get it running using your approach altering standardjbosscmp-jdbc, but on 3.2.1 I got so many errors messing with DefaultDS that I decided to set up application specific DS'es and leave the default alone, which is ofcourse the best thing to do, but I only had one app running and was to lazy ... :-)