2 Replies Latest reply on Nov 19, 2008 9:32 AM by Daniel Wachter

    Different apps, which depends on the same data model

    Daniel Wachter Newbie

      Hello together!


      I built a Web-Application with seam, which (with some help of this community) now works like a charm.
      Now I have to build another application, which depends on the same data model (database and entities) but
      has another purpose. (The first app is a backend, while the second one is the frontend for the public.


      Since I'm a newbie on J2EE I don't know all the concepts.
      To implement my second application, Well, now I have two apps (views and beans) which should use the same data model.


      Because I have two different purposes for this apps, I don't want to put them together to one single app, which is in my eyes easier to maintain.


      What are my possibilities? How can I deploy two different apps, which depends on the same data model?


      Probably this is not the right place to ask this question, because its J2EE basic stuff.
      But maybe one can give me more information (e.g. links) about this problem...


      Thanks in advance

      Daniel

        • 1. Re: Different apps, which depends on the same data model
          ben abdallah Firas Newbie

          an idea,
          I think you can do two jndi name
          you configure it if you deploly it to jboss ,
          the xml file  name-ds.xml that you can find it
          in
          JBOSS_HOME\\server\\default\\deploy




          for exemple with oracle:


          application1:


          persistance.xml:


          <?xml version="1.0" encoding="UTF-8"?>
          <!-- Persistence deployment descriptor for dev profile -->
          <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="ComexWeb">
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                <jta-data-source>java:/App1Datasource</jta-data-source>
                <properties>
                    <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect"/>
                   <property name="hibernate.hbm2ddl.auto" value="validate"/>
                   <property name="hibernate.show_sql" value="true"/>
                   <property name="hibernate.format_sql" value="true"/>
                   <property name="jboss.entity.manager.factory.jndi.name" value="java:/App1EntityManagerFactory"/>
                   <property name="hibernate.default_schema" value="Shema"/>
                </properties>
             </persistence-unit>
              
          </persistence>



          App1-ds.xml



          <?xml version="1.0" encoding="UTF-8"?>
          
          <!DOCTYPE datasources
              PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
              "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
              
          <datasources>
             
             <local-tx-datasource>
                <jndi-name>App1Datasource</jndi-name>
                <connection-url>jdbc:oracle:thin:@url:1521:nomdatabase</connection-url>
                <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                <user-name>login</user-name>
                <password>password</password>
          <!-- 
                <exception-sorter-class-name>
                   org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
                </exception-sorter-class-name>
                <metadata>
                   <type-mapping>mySQL</type-mapping>
                </metadata>
          -->
             </local-tx-datasource>
              
          </datasources>
          




          application2:



          persistance.xml



          <?xml version="1.0" encoding="UTF-8"?>
          <!-- Persistence deployment descriptor for dev profile -->
          <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="ComexWeb">
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                <jta-data-source>java:/App2Datasource</jta-data-source>
                <properties>
                    <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect"/>
                   <property name="hibernate.hbm2ddl.auto" value="validate"/>
                   <property name="hibernate.show_sql" value="true"/>
                   <property name="hibernate.format_sql" value="true"/>
                   <property name="jboss.entity.manager.factory.jndi.name" value="java:/App2EntityManagerFactory"/>
                   <property name="hibernate.default_schema" value="Shema"/>
                </properties>
             </persistence-unit>
              
          </persistence>
          



          App2-ds.xml



          <?xml version="1.0" encoding="UTF-8"?>
          
          <!DOCTYPE datasources
              PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
              "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
              
          <datasources>
             
             <local-tx-datasource>
                <jndi-name>App2Datasource</jndi-name>
                <connection-url>jdbc:oracle:thin:@url:1521:nomdatabase</connection-url>
                <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                <user-name>login</user-name>
                <password>password</password>
          <!-- 
                <exception-sorter-class-name>
                   org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
                </exception-sorter-class-name>
                <metadata>
                   <type-mapping>mySQL</type-mapping>
                </metadata>
          -->
             </local-tx-datasource>
              
          </datasources>
          


          • 2. Re: Different apps, which depends on the same data model
            Daniel Wachter Newbie

            Thank you for your answer.


            My big problem/question is, how can I have two apps which depends on the same database and on the same entities?
            In a normal Java application I can make a .jar to include in other apps.


            What is the approach to handle this in the J2EE world?