1 2 Previous Next 18 Replies Latest reply on Apr 11, 2007 3:03 PM by Alex Savitsky

    Tomcat deployment with external datasource - is it possible?

    Alex Savitsky Novice

      I'm currently trying to adopt the Seam JPA example to our Tomcat deployment guidelines, and I'm facing a problem here...

      The example uses a DataSource that is supplied by the Microcontainer, in jboss-beans.xml:

      <bean name="bookingDatasourceFactory"
       <property name="driverClass">org.hsqldb.jdbcDriver</property>
       <property name="connectionUrl">jdbc:hsqldb:.</property>
       <property name="userName">sa</property>
       <property name="jndiName">java:/DefaultDS</property>
       <property name="minSize">0</property>
       <property name="maxSize">10</property>
       <property name="blockingTimeout">1000</property>
       <property name="idleTimeout">100000</property>
       <property name="transactionManager">
       <inject bean="TransactionManager" />
       <bean name="bookingDatasource" class="java.lang.Object">
       <constructor factoryMethod="getDataSource">
       <factory bean="bookingDatasourceFactory" />

      My question is: is it possible to somehow use the DataSource that is configured in Tomcat, as in

      <?xml version="1.0" encoding="UTF-8"?>
       <Resource name="jdbc/DataSource" auth="Container"
       type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="username" password="password" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc url" />

      The idea is to be able to create data sources outside the deployed WAR, so that the same WAR could be deployed to different environments without any changes - this is a common requirement for production-level Tomcat applications.

      When I try to remove the data source definition from jboss-beans.xml, it gives me the "name not bound" exception (naturally), and I suspect that it only uses the Microcontainer's JNDI, ignoring the Tomcat-supplied one.

      Is such setup supported at all? Is there any way to configure the data source outside the WAR, while using Seam/Microcontainer/JPA stack?



        1 2 Previous Next