0 Replies Latest reply on Feb 7, 2007 1:52 PM by Greg Zoller

    Prod/Dev Datasource Problem

    Greg Zoller Newbie

      Hello,

      I used seam-gen to create a project for Eclipse. No problem getting it to generate entities for my existing tables--even the generated web app pulled back data.

      I wanted to try the prod/dev datasource distinction, so for my project (Spurs) I have Spurs-prod-ds.xml and Spurs-dev-ds.xml. The only differences are the jndi name, database url and login credentials:

      Spurs-prod-ds.xml

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


      Spurs-dev-ds.xml
      <datasources>
       <local-tx-datasource>
       <jndi-name>SpursDatasourceDev</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/spursdev</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>gregdev</user-name>
       <password>gregdev</password>
       </local-tx-datasource>
      


      Both spurs and spursdev have identical schemas and both of these database logins work fine going into MySQL manually. Inside my Spurs.ear I have a Spurs.jar with META-INF/persistence.xml:

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
       version="1.0">
      <persistence-unit name="Spurs">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/SpursDatasourceDev</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="validate"/>
       <property name="hibernate.cache.use_query_cache" value="true"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/SpursEntityManagerFactory"/>
       </properties>
       </persistence-unit>
      </persistence>
      


      Here's what happens: Seam appears to correctly find Spurs-dev-ds.xml from the jndi name when pesistence.xml is configured as above, but won't find my database tables and crashes my app. If I manually edit Spurs-dev-ds.xml and only change the tablename in the url (spursdev to spurs) and the name/pwd (gregdev to greg) to their prod counterparts everything works fine.

      Here's a clue: When aimed at prod (spurs) one line in the JBoss startup log looks like this:

      11:45:37,976 INFO [TableMetadata] table found: spurs.bucket
      


      The same line when pointed at spursdev looks like this:
      11:45:37,976 INFO [TableMetadata] table not found: bucket
      


      Notice that the prefix "spurs." is missing. Why didn't it look for "spursdev.bucket"?

      Greg