Discussions

EJB programming & troubleshooting: JBoss ear datasource.

  1. JBoss ear datasource. (2 messages)

    Hi,
    Does anyone know if it is possible to have ear file deployed on jboss with datasource bundled in it instead of having datasource xml file in jboss/server/xxx/deploy directory.
    Currently i this in my jboss-cmp xml file
    <jbosscmp-jdbc>

       <defaults>
          <datasource>java:/MyOwnDSMYSQL</datasource>
          <datasource-mapping>mySQL</datasource-mapping>
          <create-table>true</create-table>
          <remove-table>false</remove-table>
       </defaults>
    ......

    and then i have datasource file mysql-ds.xml in jboss/server/xxx/deploy which deploys the datasource using the jndi binding MyOwnDSMYSQL.

    <datasources>
      <local-tx-datasource>
        <jndi-name>MyOwnDSMYSQL</jndi-name>
        <connection-url>jdbc:mysql://localhost:3306/databasename</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <user-name>root</user-name>
        <password></password>
      </local-tx-datasource>

    </datasources>


    It'd be great if somehow the datasource stuff could be configured within my ear, and not have to copy or edit the external mysql-ds.xml file. This would allow for simple deployment of ear on jboss server, just one file.

    Any thoughts?
    thanks.

    Threaded Messages (2)

  2. JBoss ear datasource.[ Go to top ]

    In the application.xml add the following

    <module>
    <java><your_jboss_ds.xml_file></java>
    </module>

    Lets say your ds xml name is jboss-ds.xml and is available in the root of the application.xml. Then the above becomes

    <module>
    <java>jboss-ds.xml</java>
    </module>

    If your ds.xml is inside conf/ folder of the ear then try

    <module>
    <java>conf/jboss-ds.xml</java>
    </module>

    Note: Choose a better name for your ds.xml file.
  3. Jboss war datasource[ Go to top ]

    In the application.xml add the following





    Lets say your ds xml name is jboss-ds.xml and is available in the root of the application.xml. Then the above becomes


    jboss-ds.xml


    If your ds.xml is inside conf/ folder of the ear then try


    conf/jboss-ds.xml


    Note: Choose a better name for your ds.xml file.
    What if you are deloying a war instead? Adding mysql-ds.xml in the application.xml does not load the datasources in JBoss 4.2.2