2 Replies Latest reply on Oct 14, 2003 1:02 AM by kentcb

    Multiple data sources for CMP

    kentcb Newbie

      Hi All,

      I am using JBoss 3.2.1, CMP, and XDoclet for code / deployment generation . . .

      How do I have different EJBs in my application connect to different data sources? Using BMP, you can simply look up the data source using a different JNDI name. With CMP, I can't see how to do this.

      If I specify only the datasource for the EJB, JBoss complains:

      Error in jbosscmp-jdbc.xml : datasource-mapping not found

      However, this information is generated via XDoclet like this:

      * @jboss.persistence
      * create-table="false"
      * remove-table="false"
      * datasource="jdbc/esm_auditing"

      so I definitely don't want to put something like this in my source:

      * @jboss.persistence
      * create-table="false"
      * remove-table="false"
      * datasource="jdbc/esm_auditing"
      * datasource-mapping="Sybase"

      for obvious reasons . . .

      I must be missing something obvious here but I have done a search and couldn't find anything covering this issue.

      Thanks,
      Kent

        • 1. Re: Multiple data sources for CMP
          Jochen Cordes Novice

          Hi Kent !

          AFAIK you have to define the datasource-mapping along with the datasource (how else could the container guess which database-type is actually used ?). But you can get past the limitation of setting a static value in XDoclet. Just specify a property, lets say datasource-jndi-name and datasource-mapping in build.xml. Then just use

          @jboss.persistence
          * create-table="false"
          * remove-table="false"
          * datasource="${datasource-jndi-name}"
          * datasource-mapping="${datasource-mapping}"

          HTH,

          Jochen.

          • 2. Re: Multiple data sources for CMP
            kentcb Newbie

            Thanks Jochen - that helps a little.

            I guess my aim is to avoid environment-specific information being included as part of the build. If I can avoid this then I can deploy the same EAR regardless of the environment. Settings specific to the environment can then be configured separately.

            I'm not sure whether that utopia is even possible. Anyone else been faced with the same problem?

            Thanks,
            Kent