5 Replies Latest reply on Apr 17, 2004 3:36 PM by sesques

    org.jboss.deployment.DeploymentException: No ejb-relationshi

    troypoppe Newbie

      I am developing a set of CMP EJBs that have CMRs using XDoclet to generate most of the code required. When I build and deploy this application, I get the following exception for each CMP entity bean that I have developed:

      org.jboss.deployment.DeploymentException: No ejb-relationship-role-name element found

      This is an example of two of my beans, and the resulting ejb-jar.xml and jbosscmp-jdbc.xml files.

      
      package gov.doe.eia.party;
      
      import gov.doe.eia.party.interfaces.PartyLocal;
      import gov.doe.eia.party.interfaces.PartyLocalHome;
      import gov.doe.eia.party.util.PartyUtil;
      import gov.doe.eia.party.vo.PartyValue;
      import gov.doe.eia.party.vo.PersonValue;
      
      import java.util.Collection;
      
      import javax.ejb.CreateException;
      import javax.ejb.EntityBean;
      import javax.ejb.FinderException;
      import javax.naming.NamingException;
      
      /**
       * @ejb.bean name="Person"
       * jndi-name="ejb/Person"
       * local-jndi-name="ejb/PersonLocal"
       * type="CMP"
       * primkey-field="personID"
       * cmp-version="2.x"
       * view-type = "local"
       *
       * @ejb.persistence
       * table-name = "person"
       *
       * @jboss.persistence
       * datasource = "java:/jdbc/PartyDS"
       * datasource-mapping = "Oracle9i"
       * create-table = "false"
       * remove-table = "false"
       *
       * @ejb.value-object
       * name = "Person"
       * match = "*"
       *
       * @ejb.ejb-ref
       * ejb-name = "Party"
       * ref-name = "ejb/PartyLocal"
       * view-type = "local"
       */
      public abstract class PersonBean implements EntityBean
      {
      
       /**
       * Returns the personID
       * @return the personID
       *
       * @ejb.persistent-field
       * @ejb.persistence
       * column-name="personid"
       * sql-type="NUMBER"
       * @ejb.pk-field
       * @ejb.interface-method
       * view-type = "local"
       *
       */
       public abstract java.lang.Integer getPersonID();
      
       /**
       * Sets the personID
       *
       * @param java.lang.Integer the new personID value
       *
       * @ejb.interface-method
       * view-type = "local"
       */
       public abstract void setPersonID(java.lang.Integer personID);
      
       /**
       *
       * @ejb.interface-method
       * view-type = "local"
       *
       * @return
       */
       public abstract PersonValue getPersonValue();
      
       /**
       * @ejb.interface-method
       * view-type = "local"
       *
       * @param valueHolder
       */
       public abstract void setPersonValue(PersonValue valueHolder);
      
       // -------------------------- RELATIONS ---------------------------------//
      
       /**
       * @ejb.relation
       * name = "RoleInstancePerson"
       * role-name = "PersonHasRoleInstances"
       *
       * @ejb.interface-method
       * view-type = "local"
       *
       * @ejb.value-object
       * compose="gov.doe.eia.party.vo.RoleInstanceValue"
       * compose-name="RoleInstance"
       * members="gov.doe.eia.party.interfaces.RoleInstanceLocal"
       * member-name="RoleInstance"
       * relation="external"
       * type="Collection"
       *
       * @jboss.relation
       * fk-column = "personID"
       * related-pk-field = "assignedPerson"
       *
       * @author TPO
       */
       public abstract Collection getRoleInstances();
      
       /**
       * @ejb.interface-method
       * view-type = "local"
       *
       * @jboss.relation
       * fk-column = "personID"
       * related-pk-field = "assignedPerson"
       *
       * @author TPO
       */
       public abstract void setRoleInstances(Collection roleInstances);
      
       /**
       * @ejb.relation
       * name = "PersonParty"
       * role-name = "PersonIsAParty"
       * target-ejb = "Party"
       *
       * @ejb.interface-method
       * view-type = "local"
       *
       * @jboss.relation
       * fk-column = "personID"
       * related-pk-field = "partyID"
       *
       * @ejb.value-object
       * relation = "external"
       *
       * @author TPO
       */
       public abstract PartyLocal getParty();
      
       /**
       * @ejb.interface-method
       * view-type = "local"
       *
       * @jboss.relation
       * fk-column = "personID"
       * related-pk-field = "partyID"
       *
       * @author TPO
       */
       public abstract void setParty(PartyLocal party);
      
       // -------------------------- CREATES ---------------------------------//
      
       /**
       * The ejbCreate method.
       *
       * @ejb.create-method
       */
       public java.lang.Integer ejbCreate(PersonValue personValue)
       throws javax.ejb.CreateException
       {
       // EJB 2.0 spec says return null for CMP ejbCreate methods.
       PartyValue partyValue = new PartyValue(null, new Integer(PartyType.PERSON));
       try
       {
       PartyLocalHome plHome = PartyUtil.getLocalHome();
       PartyLocal pl = plHome.create(partyValue);
       partyValue = pl.getPartyValue();
      
       personValue.setPersonID(partyValue.getPartyID());
       setPersonValue(personValue);
       }
       catch ( NamingException ex )
       {
       }
       catch ( CreateException ex )
       {
       }
      
       return null;
       }
      
       /**
       * The container invokes this method immediately after it calls ejbCreate.
       *
       */
       public void ejbPostCreate(PersonValue personValue)
       throws javax.ejb.CreateException
       {
       try
       {
       PartyLocalHome plHome = PartyUtil.getLocalHome();
       PartyLocal pl = plHome.findByPrimaryKey(getPersonID());
      
       setParty(pl);
       }
       catch ( NamingException ex )
       {
       }
       catch ( FinderException ex )
       {
       }
       }
      }
      


      package gov.doe.eia.party;
      
      import gov.doe.eia.party.vo.PartyValue;
      
      import javax.ejb.EntityBean;
      
      /**
       * @ejb.bean
       * name="Party"
       * jndi-name="ejb/Party"
       * local-jndi-name = "ejb/PartyLocal"
       * type="CMP"
       * primkey-field="partyID"
       * cmp-version="2.x"
       * view-type = "local"
       *
       * @ejb.persistence
       * table-name = "party"
       *
       * @jboss.persistence
       * datasource = "java:/jdbc/PartyDS"
       * datasource-mapping = "Oracle9i"
       * create-table = "false"
       * remove-table = "false"
       *
       * @ejb.value-object
       * name = "Party"
       * match = "*"
       *
       * @ejb.ejb-ref
       * ejb-name = "SequenceManager"
       * ref-name = "ejb/SequenceManagerLocal"
       * view-type = "local"
       */
      public abstract class PartyBean implements EntityBean
      {
      
       /**
       * Returns the partyID
       * @return the partyID
       *
       * @ejb.persistent-field
       * @ejb.persistence
       * column-name="partyID"
       * sql-type="NUMBER"
       * @ejb.pk-field
       * @ejb.interface-method
       *
       */
       public abstract java.lang.Integer getPartyID();
      
       /**
       * Sets the partyID
       *
       * @param java.lang.Integer the new partyID value
       *
       * @ejb.interface-method
       */
       public abstract void setPartyID(java.lang.Integer partyID);
      
       /**
       * Returns the partyTypeID
       * @return the partyTypeID
       *
       * @ejb.persistent-field
       * @ejb.persistence
       * column-name="partyTypeID"
       * sql-type="NUMBER"
       *
       * @ejb.interface-method
       *
       */
       public abstract java.lang.Integer getPartyTypeID();
      
       /**
       * Sets the partyTypeID
       *
       * @param java.lang.Integer the new partyTypeID value
       *
       * @ejb.interface-method
       */
       public abstract void setPartyTypeID(java.lang.Integer partyTypeID);
      
       /**
       *
       * @ejb.interface-method
       * view-type = "local"
       *
       * @return
       */
       public abstract PartyValue getPartyValue();
      
       /**
       * @ejb.interface-method
       * view-type = "local"
       *
       * @param valueHolder
       */
       public abstract void setPartyValue(PartyValue valueHolder);
      
       // -------------------------- RELATIONS ---------------------------------//
      
       // -------------------------- CREATES ---------------------------------//
      
       /**
       * The ejbCreate method.
       *
       * @ejb.create-method
       */
       public java.lang.Integer ejbCreate(PartyValue partyValue)
       throws javax.ejb.CreateException
       {
       // EJB 2.0 spec says return null for CMP ejbCreate methods.
       // TODO: set PK!!
       setPartyValue(partyValue);
       return null;
       }
      
       /**
       * The container invokes this method immediately after it calls ejbCreate.
       *
       */
       public void ejbPostCreate(PartyValue partyValue)
       throws javax.ejb.CreateException
       {
       }
      
      }
      



      <entity >
      <description><![CDATA[]]></description>

      <ejb-name>Party</ejb-name>

      <local-home>gov.doe.eia.party.interfaces.PartyLocalHome</local-home>
      <local>gov.doe.eia.party.interfaces.PartyLocal</local>

      <ejb-class>gov.doe.eia.party.cmp.PartyCMP</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      <reentrant>False</reentrant>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Party</abstract-schema-name>
      <cmp-field >
      <description><![CDATA[Returns the partyID]]></description>
      <field-name>partyID</field-name>
      </cmp-field>
      <cmp-field >
      <description><![CDATA[Returns the partyTypeID]]></description>
      <field-name>partyTypeID</field-name>
      </cmp-field>
      <primkey-field>partyID</primkey-field>

      <ejb-local-ref >
      <ejb-ref-name>ejb/SequenceManagerLocal</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <local-home>gov.doe.eia.party.interfaces.SequenceManagerLocalHome</local-home>
      <local>gov.doe.eia.party.interfaces.SequenceManagerLocal</local>
      <ejb-link>SequenceManager</ejb-link>
      </ejb-local-ref>

      <!-- Write a file named ejb-finders-PartyBean.xml if you want to define extra finders. -->
      </entity>

      <entity >
      <description><![CDATA[]]></description>

      <ejb-name>Person</ejb-name>

      <local-home>gov.doe.eia.party.interfaces.PersonLocalHome</local-home>
      <local>gov.doe.eia.party.interfaces.PersonLocal</local>

      <ejb-class>gov.doe.eia.party.cmp.PersonCMP</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      <reentrant>False</reentrant>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Person</abstract-schema-name>
      <cmp-field >
      <description><![CDATA[Returns the personID]]></description>
      <field-name>personID</field-name>
      </cmp-field>
      <cmp-field >
      <description><![CDATA[Returns the lastName]]></description>
      <field-name>lastName</field-name>
      </cmp-field>
      <cmp-field >
      <description><![CDATA[Returns the firstName]]></description>
      <field-name>firstName</field-name>
      </cmp-field>
      <primkey-field>personID</primkey-field>

      <ejb-local-ref >
      <ejb-ref-name>ejb/PartyLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>gov.doe.eia.party.interfaces.PartyLocalHome</local-home>
      <local>gov.doe.eia.party.interfaces.PartyLocal</local>
      <ejb-link>Party</ejb-link>
      </ejb-local-ref>

      <!-- Write a file named ejb-finders-PersonBean.xml if you want to define extra finders. -->
      </entity>
      <ejb-relation >
      <ejb-relation-name>PersonParty</ejb-relation-name>

      <ejb-relationship-role >
      <ejb-relationship-role-name>PersonIsAParty</ejb-relationship-role-name>
      <multiplicity>One</multiplicity>
      <relationship-role-source >
      <ejb-name>Person</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>party</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role >
      <multiplicity>One</multiplicity>
      <relationship-role-source >
      <ejb-name>Party</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>

      </ejb-relation>



      <entity>
      <ejb-name>Party</ejb-name>
      <datasource>java:/jdbc/PartyDS</datasource>
      <datasource-mapping>Oracle9i</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <table-name>party</table-name>

      <cmp-field>
      <field-name>partyID</field-name>
      <column-name>partyID</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>partyTypeID</field-name>
      <column-name>partyTypeID</column-name>

      </cmp-field>

      <!-- jboss 3.2 features -->
      <!-- optimistic locking does not express the exclusions needed -->
      </entity>

      <entity>
      <ejb-name>Person</ejb-name>
      <datasource>java:/jdbc/PartyDS</datasource>
      <datasource-mapping>Oracle9i</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <table-name>person</table-name>

      <cmp-field>
      <field-name>personID</field-name>
      <column-name>personid</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      <column-name>lastName</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      <column-name>firstName</column-name>

      </cmp-field>

      <!-- jboss 3.2 features -->
      <!-- optimistic locking does not express the exclusions needed -->
      </entity>

      <ejb-relation>
      <ejb-relation-name>PersonParty</ejb-relation-name>

      <ejb-relationship-role>
      <ejb-relationship-role-name>PersonIsAParty</ejb-relationship-role-name>
      <key-fields/>

      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name></ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>partyID</field-name>
      <column-name>personID</column-name>
      </key-field>
      </key-fields>

      </ejb-relationship-role>
      </ejb-relation>


      Can anyone help me, I cant see find anything wrong with this. I certainly dont understand why I am getting that error.

      Thanks.

      Troy Poppe