4 Replies Latest reply on Nov 4, 2013 8:41 AM by François-Xavier Seheut de Ronchi

    Multiple version of application's ear same JBoss AS 6.0.1 all point to same datasource.

    François-Xavier Seheut de Ronchi Newbie

      Hello everyone,

       

      I think I'm missing something on the way datasources and ears are linked in JBoss.

       

      A little presentation of what I have :

       

      In JBoss 6.0.1/server/default/ :

      File nameContent
      application.vA.ear

      persistence.xml :

      <persistence-unit name="appA">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <jta-data-source>java:/appVADatasource</jta-data-source>

        ...

        <properties>

                  <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />

                  <property name="hibernate.hbm2ddl.auto" value="validate" />

                  <property name="hibernate.show_sql" value="false" />

                  <property name="hibernate.format_sql" value="true" />

                  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />

       

                  <property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory" />

                  <property name="jboss.entity.manager.factory.jndi.name" value="java:/viewerEntityManagerFactory" />

                  <!-- Enable Hibernate Search In Memory Configuration: use a file system based index -->

                  <property name="hibernate.search.default.directory_provider" value="com.blabla.wp6.viewer.search.directory.StandaloneDirectoryProvider" />

                  <property name="hibernate.search.indexing_strategy" value="manual" />

         </properties>

      </persistence-unit>

      application.vA-ds.xml

       

      <datasources>

          <local-tx-datasource>

              <jndi-name>appVADatasource</jndi-name>

              <use-java-context>true</use-java-context>

              <connection-url>jdbc:mysql://localhost:3306/appA</connection-url>

              <driver-class>org.mysqldb.jdbcDriver</driver-class>

              <user-name>root</user-name>

              <password></password>

          </local-tx-datasource>

      </datasources>

      application.vB.ear

      persistence.xml :

      <persistence-unit name="appB">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <jta-data-source>java:/appVBDatasource</jta-data-source>

        ...

        <properties>

                  <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />

                  <property name="hibernate.hbm2ddl.auto" value="validate" />

                  <property name="hibernate.show_sql" value="false" />

                  <property name="hibernate.format_sql" value="true" />

                  <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />

                  <property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory" />

                  <property name="jboss.entity.manager.factory.jndi.name" value="java:/viewerEntityManagerFactory" />

                  <!-- Enable Hibernate Search In Memory Configuration: use a file system based index -->

                  <property name="hibernate.search.default.directory_provider" value="com.blabla.wp6.viewer.search.directory.StandaloneDirectoryProvider" />

                  <property name="hibernate.search.indexing_strategy" value="manual" />

         </properties>

      </persistence-unit>

      application.vB-ds.xml

        <datasources>

          <local-tx-datasource>

              <jndi-name>appVBDatasource</jndi-name>

              <use-java-context>true</use-java-context>

              <connection-url>jdbc:mysql://localhost:3306/appB</connection-url>

              <driver-class>org.mysqldb.jdbcDriver</driver-class>

              <user-name>root</user-name>

              <password></password>

          </local-tx-datasource>

      </datasources>

       

      When I start the server, I see that the two persistence unit are binded to the GLOBAL jndi.

      But when the server is started and I connect to both applications, both application use the same datasource.

       

      So I'm wondering what am I missing to tell application A to use Datasource A and application B to use datasource B.

       

      Any help would be greatly appreciated.

       

      Thanks in advance.