2 Replies Latest reply on Apr 23, 2003 9:13 AM by freiburg

    Help with deployment descriptors

    freiburg Newbie

      Hi,
      I try to deploy an application that uses more database tables and relationship. The deployer tell me that it needs more info in the deploy descriptor. Can someone send me examples of complete deploy descriptors? I need ejb-jar.xml, jbosscmp-jdbc and other ones if they exists.
      I use entity bean with Container Managed Persistence.
      Thank you very much,
      Andrea

      My email is andrones@tiscali.it

        • 1. Re: Help with deployment descriptors
          Pablo Delgado Newbie

          Hello, I post here my files that work with no problem with JBOSS 3.2 and CMP. The files are generated using xdoclet version 1.2beta2 (I encourage you to use it).
          The example is 2 EB with a relation one-to-many from "Token" to "Availability". I hope this help you.

          ejb-jar.xml
          ========
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

          <ejb-jar >

          <![CDATA[No Description.]]>
          <display-name>Generated by XDoclet</display-name>
          <enterprise-beans>

          <![CDATA[Token description]]>
          <display-name>Token display</display-name>
          <ejb-name>Token</ejb-name>
          <local-home>ejb.EntityBean.Token.TokenLocalHome</local-home>
          ejb.EntityBean.Token.TokenLocal
          <ejb-class>ejb.EntityBean.Token.TokenCMP</ejb-class>
          <persistence-type>Container</persistence-type>
          <prim-key-class>java.lang.Long</prim-key-class>
          False
          <cmp-version>2.x</cmp-version>
          <abstract-schema-name>Token</abstract-schema-name>
          <cmp-field >
          <![CDATA[]]>
          <field-name>idtoken</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[]]>
          <field-name>idtokentype</field-name>
          </cmp-field>
          <primkey-field>idtoken</primkey-field>
          <resource-ref >
          <res-ref-name>jdbc/myDB</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
          </resource-ref>



          <![CDATA[Availability description]]>
          <display-name>Availability display</display-name>

          <ejb-name>Availability</ejb-name>
          <local-home>ejb.EntityBean.Availability.AvailabilityLocalHome</local-home>
          ejb.EntityBean.Availability.AvailabilityLocal
          <ejb-class>ejb.EntityBean.Availability.AvailabilityCMP</ejb-class>
          <persistence-type>Container</persistence-type>
          <prim-key-class>ejb.EntityBean.Availability.AvailabilityPK</prim-key-class>
          False
          <cmp-version>2.x</cmp-version> <abstract-schema-name>Availability</abstract-schema-name>
          <cmp-field>
          <![CDATA[]]>
          <field-name>initdate</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[]]>
          <field-name>idslot</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[]]>
          <field-name>status</field-name>
          </cmp-field>
          <resource-ref >
          <res-ref-name>jdbc/mrs</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
          </resource-ref>


          <!-- Relationships -->

          <ejb-relation >
          <ejb-relation-name>token-availability</ejb-relation-name>
          <ejb-relationship-role>
          <ejb-relationship-role-name>availability-belongs-to-token</ejb-relationship-role-name>
          Many
          <cascade-delete/>
          <relationship-role-source >
          <ejb-name>Availability</ejb-name>
          </relationship-role-source>
          <cmr-field >
          <cmr-field-name>token</cmr-field-name>
          </cmr-field>
          </ejb-relationship-role>

          <ejb-relationship-role >
          <ejb-relationship-role-name>token-has-availabilitiess</ejb-relationship-role-name>
          One
          <relationship-role-source >
          <ejb-name>Token</ejb-name>
          </relationship-role-source>
          <cmr-field >
          <cmr-field-name>availabilities</cmr-field-name>
          <cmr-field-type>java.util.Collection</cmr-field-type>
          </cmr-field>
          </ejb-relationship-role>
          </ejb-relation>

          </ejb-jar>

          jboss.xml
          =======
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">

          <enterprise-beans>

          <ejb-name>Token</ejb-name>
          <local-jndi-name>LocalToken</local-jndi-name>
          <resource-ref>
          <res-ref-name>jdbc/myDS</res-ref-name>
          <jndi-name>java:/PostgresDS</jndi-name>
          </resource-ref>


          <ejb-name>Availability</ejb-name>
          <local-jndi-name>LocalAvailability</local-jndi-name>
          <resource-ref>
          <res-ref-name>jdbc/myDS</res-ref-name>
          <jndi-name>java:/PostgresDS</jndi-name>
          </resource-ref>

          </enterprise-beans>

          jbosscmp-jdbc.xml
          ==============

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">
          <jbosscmp-jdbc>

          java:/PostgresDS
          <datasource-mapping>PostgreSQL 7.2</datasource-mapping>

          <enterprise-beans>


          <ejb-name>Availability</ejb-name>
          <table-name>availability</table-name>
          <cmp-field>
          <field-name>initdate</field-name>
          <column-name>initdate</column-name>
          <jdbc-type>DATE</jdbc-type>
          <sql-type>timestamp without time zone</sql-type>
          </cmp-field>
          <cmp-field>
          <field-name>idslot</field-name>
          <column-name>id_slot_fk</column-name>
          <jdbc-type>INTEGER</jdbc-type>
          <sql-type>integer</sql-type>
          </cmp-field>
          <cmp-field>
          <field-name>status</field-name>
          <column-name>status</column-name>
          <jdbc-type>BIT</jdbc-type>
          <sql-type>boolean</sql-type>
          </cmp-field>


          <ejb-name>Token</ejb-name>
          <table-name>token</table-name>
          <cmp-field>
          <field-name>idtoken</field-name>
          <column-name>id_token</column-name>
          <jdbc-type>BIGINT</jdbc-type>
          <sql-type>bigint</sql-type>
          </cmp-field>
          <cmp-field>
          <field-name>idtokentype</field-name>
          <column-name>id_tokentype_fk</column-name>
          <jdbc-type>INTEGER</jdbc-type>
          <sql-type>integer</sql-type>
          </cmp-field>

          </enterprise-beans>

          <ejb-relation>
          <ejb-relation-name>token-availability</ejb-relation-name>
          <foreign-key-mapping/>
          <ejb-relationship-role> <ejb-relationship-role-name>availability-belongs-to-token</ejb-relationship-role-name>
          <fk-constraint>true</fk-constraint>
          <key-fields/>
          </ejb-relationship-role>
          <ejb-relationship-role>
          <ejb-relationship-role-name>token-has-availabilitiess</ejb-relationship-role-name>
          <key-fields>
          <key-field>
          <field-name>idtoken</field-name>
          <column-name>id_token_fk</column-name>
          </key-field>
          </key-fields>
          </ejb-relationship-role>
          </ejb-relation>

          </jbosscmp-jdbc>

          All of these should create two tables in your DB.

          myDB=# \d token
          Table "public.token"
          Column | Type | Modifiers
          ---------------------+---------+-----------
          id_token | bigint | not null
          id_tokentype_fk | integer |
          Indexes: pk_token primary key btree (id_token)

          myDB=# \d availability
          Table "public.availability"
          Column | Type | Modifiers
          -------------+-----------------------------+-----------
          id_token_fk | bigint | not null
          initdate | timestamp without time zone | not null
          id_slot_fk | integer | not null
          status | boolean | not null
          Indexes: pk_availability primary key btree (initdate, id_slot_fk)

          The column "id_token_fk" is imported from Token to Availability with the relationship (CMR field).






          • 2. Re: Help with deployment descriptors
            freiburg Newbie

            Really thank you very much. Now it works! :))
            Bye bye!
            Andrea