4 Replies Latest reply on May 24, 2002 3:37 PM by Sundeep Kadakia

    CMP field for key not found: field name=company

    Sundeep Kadakia Newbie

      Hi,

      I have got the latest source code (JBoss 3.1) last night and built it successfully. When I deploy my application EJB beans it gives me following stack trace:

      2002-05-20 18:25:29,843 INFO [org.jboss.ejb.EjbModule] Creating WebClassLoader of class org.jboss.web.WebClassLoader
      2002-05-20 18:25:29,873 INFO [org.jboss.ejb.EntityContainer] Creating
      2002-05-20 18:25:29,893 INFO [org.jboss.ejb.plugins.EntityInstancePool] Creating
      2002-05-20 18:25:29,893 INFO [org.jboss.ejb.plugins.EntityInstancePool] Created
      2002-05-20 18:25:30,274 ERROR [org.jboss.ejb.EntityContainer] Initialization failed
      org.jboss.deployment.DeploymentException: CMP field for key not found: field name=company
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.loadKeyFields(JDBCRelationshipRoleMetaData.java:374)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.init(JDBCRelationshipRoleMetaData.java:157)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationMetaData.(JDBCRelationMetaData.java:308)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.(JDBCApplicationMetaData.java:383)
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:75)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:602)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.create(JDBCStoreManager.java:322)
      at org.jboss.ejb.plugins.CMPPersistenceManager.create(CMPPersistenceManager.java:155)
      at org.jboss.ejb.EntityContainer.createService(EntityContainer.java:318)
      at org.jboss.system.ServiceMBeanSupport.create(ServiceMBeanSupport.java:170)
      at org.jboss.ejb.Container.invoke(Container.java:778)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1024)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:867)
      at $Proxy0.create(Unknown Source)
      at org.jboss.system.ServiceController.create(ServiceController.java:271)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
      at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
      at $Proxy17.create(Unknown Source)
      at org.jboss.ejb.EjbModule.createService(EjbModule.java:390)
      at org.jboss.system.ServiceMBeanSupport.create(ServiceMBeanSupport.java:170)

      I have attached, ejb-jar.xml, jbosscmp_jdbc.xml and jboss.xml. I will really appreciate if someone can help me diagnose this problem.

      Somehow attachments not working, so here are the files:

      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">
      <!-- Created by sundeep on January 21, 2002, 3:21 PM -->

      <ejb-jar>
      JBoss application
      <display-name>Signup EJB</display-name>
      <resource-ref>
      The default MS SQLDS
      <res-ref-name>AIMDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      <enterprise-beans>

      <ejb-name>Signup</ejb-name>
      com.atindiamall.ejb.signin.SignupHome
      com.atindiamall.ejb.signin.Signup
      <ejb-class>com.atindiamall.ejb.signin.SignupBean</ejb-class>
      <session-type>Stateful</session-type>
      <transaction-type>Container</transaction-type>



      <ejb-name>SequenceSession</ejb-name>
      <local-home>com.atindiamall.ejb.seqgen.SequenceSessionHome</local-home>
      com.atindiamall.ejb.seqgen.SequenceSession
      <ejb-class>com.atindiamall.ejb.seqgen.SequenceSessionBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <env-entry>

      <env-entry-name>retryCount</env-entry-name>
      <env-entry-type>java.lang.Integer</env-entry-type>
      <env-entry-value>5</env-entry-value>
      </env-entry>
      <env-entry>

      <env-entry-name>blockSize</env-entry-name>
      <env-entry-type>java.lang.Integer</env-entry-type>
      <env-entry-value>10</env-entry-value>
      </env-entry>



      <ejb-name>Sequence</ejb-name>
      <local-home>com.atindiamall.ejb.seqgen.SequenceHome</local-home>
      com.atindiamall.ejb.seqgen.Sequence
      <ejb-class>com.atindiamall.ejb.seqgen.SequenceBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Sequences</abstract-schema-name>
      <cmp-field><field-name>index</field-name></cmp-field>
      <cmp-field><field-name>name</field-name></cmp-field>
      <primkey-field>name</primkey-field>
      <transaction-type>Container</transaction-type>



      <ejb-name>Address</ejb-name>
      <local-home>com.atindiamall.ejb.biz.AddressHome</local-home>
      com.atindiamall.ejb.biz.Address
      <ejb-class>com.atindiamall.ejb.biz.AddressBean</ejb-class>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <persistence-type>Container</persistence-type>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Address</abstract-schema-name>
      <cmp-field><field-name>addressId</field-name></cmp-field>
      <cmp-field><field-name>addressOne</field-name></cmp-field>
      <cmp-field><field-name>addressTwo</field-name></cmp-field>
      <cmp-field><field-name>city</field-name></cmp-field>
      <cmp-field><field-name>state</field-name></cmp-field>
      <cmp-field><field-name>zipcode</field-name></cmp-field>
      <cmp-field><field-name>country</field-name></cmp-field>
      <cmp-field><field-name>phoneNumber</field-name></cmp-field>
      <cmp-field><field-name>extension</field-name></cmp-field>
      <cmp-field><field-name>faxNumber</field-name></cmp-field>
      <primkey-field>addressId</primkey-field>
      <transaction-type>Container</transaction-type>


      <ejb-name>Login</ejb-name>
      <local-home>com.atindiamall.ejb.login.LoginHome</local-home>
      com.atindiamall.ejb.login.Login
      <ejb-class>com.atindiamall.ejb.login.LoginBean</ejb-class>
      <prim-key-class>java.lang.Integer</prim-key-class>
      Flase
      <persistence-type>Container</persistence-type>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Logins</abstract-schema-name>
      <cmp-field><field-name>loginId</field-name></cmp-field>
      <cmp-field><field-name>company</field-name></cmp-field>
      <cmp-field><field-name>userStrId</field-name></cmp-field>
      <cmp-field><field-name>password</field-name></cmp-field>
      <cmp-field><field-name>salt</field-name></cmp-field>
      <cmp-field><field-name>hintQuestion</field-name></cmp-field>
      <cmp-field><field-name>hintAnswer</field-name></cmp-field>
      <cmp-field><field-name>hintSalt</field-name></cmp-field>
      <primkey-field>loginId</primkey-field>
      <transaction-type>Container</transaction-type>


      <query-method>
      <method-name>findByUserStrId</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      <![CDATA[SELECT OBJECT(a) FROM Logins a WHERE a.userStrId = ?1]]>
      </ejb-ql>




      <ejb-name>Person</ejb-name>
      <local-home>com.atindiamall.ejb.biz.PersonHome</local-home>
      com.atindiamall.ejb.biz.Person
      <ejb-class>com.atindiamall.ejb.biz.PersonBean</ejb-class>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <persistence-type>Container</persistence-type>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Persons</abstract-schema-name>
      <cmp-field><field-name>personId</field-name></cmp-field>
      <cmp-field><field-name>roleId</field-name></cmp-field>
      <cmp-field><field-name>firstName</field-name></cmp-field>
      <cmp-field><field-name>middleInitial</field-name></cmp-field>
      <cmp-field><field-name>title</field-name></cmp-field>
      <cmp-field><field-name>homePhone</field-name></cmp-field>
      <cmp-field><field-name>emailAddr</field-name></cmp-field>
      <cmp-field><field-name>address</field-name></cmp-field>
      <cmp-field><field-name>shipAddress</field-name></cmp-field>
      <cmp-field><field-name>billAddress</field-name></cmp-field>
      <cmp-field><field-name>birthDate</field-name></cmp-field>
      <cmp-field><field-name>gender</field-name></cmp-field>
      <cmp-field><field-name>signupDate</field-name></cmp-field>
      <primkey-field>personId</primkey-field>
      <transaction-type>Container</transaction-type>


      <ejb-name>Company</ejb-name>
      <local-home>com.atindiamall.ejb.biz.CompanyHome</local-home>
      com.atindiamall.ejb.biz.Company
      <ejb-class>com.atindiamall.ejb.biz.CompanyBean</ejb-class>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <persistence-type>Container</persistence-type>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Companies</abstract-schema-name>
      <cmp-field><field-name>companyId</field-name></cmp-field>
      <cmp-field><field-name>businessName</field-name></cmp-field>
      <cmp-field><field-name>contactPerson</field-name></cmp-field>
      <cmp-field><field-name>address</field-name></cmp-field>
      <cmp-field><field-name>offercodeId</field-name></cmp-field>
      <cmp-field><field-name>signupDate</field-name></cmp-field>
      <cmp-field><field-name>terminationDate</field-name></cmp-field>
      <cmp-field><field-name>terminationReason</field-name></cmp-field>
      <primkey-field>companyId</primkey-field>
      <transaction-type>Container</transaction-type>


      <ejb-name>User</ejb-name>
      <local-home>com.atindiamall.ejb.user.UserHome</local-home>
      com.atindiamall.ejb.user.User
      <ejb-class>com.atindiamall.ejb.user.UserBean</ejb-class>
      <prim-key-class>com.atindiamall.ejb.biz.Person</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <persistence-type>Container</persistence-type>
      <abstract-schema-name>Users</abstract-schema-name>
      <cmp-field><field-name>person</field-name></cmp-field>
      <cmp-field><field-name>login</field-name></cmp-field>
      <primkey-field>person</primkey-field>
      <transaction-type>Container</transaction-type>


      <query-method>
      <method-name>findByLoginId</method-name>
      <method-params>
      <method-param>com.atindiamall.ejb.login.Login</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      <![CDATA[SELECT OBJECT(b) FROM Users b WHERE b.login = ?1]]>
      </ejb-ql>



      </enterprise-beans>

      <assembly-descriptor>
      <container-transaction>

      <ejb-name>Signup</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>

      <ejb-name>Sequence</ejb-name>
      <method-name>getValueAfterIncrementingBy</method-name>

      <trans-attribute>RequiresNew</trans-attribute>
      </container-transaction>
      <container-transaction>

      <ejb-name>SequenceSession</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>

      <container-transaction>

      <ejb-name>Company</ejb-name>
      <method-intf>Local</method-intf>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>

      <ejb-name>Login</ejb-name>
      <method-intf>Local</method-intf>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>

      <ejb-name>Person</ejb-name>
      <method-intf>Local</method-intf>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction>

      <ejb-name>User</ejb-name>
      <method-intf>Local</method-intf>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>


      <ejb-relation>
      <ejb-relation-name>Login-Company</ejb-relation-name>
      <!-- first half of relationship, Login side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Login-to-Company
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Login</ejb-name>
      </relationship-role-source>
      <cmr-field><cmr-field-name>company</cmr-field-name></cmr-field>
      </ejb-relationship-role>
      <!-- second half of relationship, Company side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Company-has-login
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Company</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>User-Login</ejb-relation-name>
      <!-- first half of relationship, User side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      User-has-Login
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>User</ejb-name>
      </relationship-role-source>
      <cmr-field><cmr-field-name>login</cmr-field-name></cmr-field>
      </ejb-relationship-role>
      <!-- second half of relationship, Login side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Login-for-User
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Login</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Company-Address</ejb-relation-name>
      <!-- first half of relationship, Company side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Company-has-Address
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Company</ejb-name>
      </relationship-role-source>
      <cmr-field><cmr-field-name>address</cmr-field-name></cmr-field>
      </ejb-relationship-role>
      <!-- second half of relationship, Address side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Address-for-Company
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Address</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Company-Person</ejb-relation-name>
      <!-- first half of relationship, User side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Company-has-Contact-Person-or-User
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Company</ejb-name>
      </relationship-role-source>
      <cmr-field><cmr-field-name>contactPerson</cmr-field-name></cmr-field>
      </ejb-relationship-role>
      <!-- second half of relationship, Person side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Contact-Person-or-User-of-Company
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Person</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Person-Address</ejb-relation-name>
      <!-- first half of relationship, Person side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Person-has-Address
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Person</ejb-name>
      </relationship-role-source>
      <cmr-field><cmr-field-name>address</cmr-field-name></cmr-field>
      </ejb-relationship-role>
      <!-- second half of relationship, Address side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Address-of-Person
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Address</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Person-Shipping-Address</ejb-relation-name>
      <!-- first half of relationship, Person side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Person-has-ShippingAddress
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Person</ejb-name>
      </relationship-role-source>
      <cmr-field><cmr-field-name>shippingAddress</cmr-field-name></cmr-field>
      </ejb-relationship-role>
      <!-- second half of relationship, Address side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      ShippingAddress-of-Person
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Address</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Person-Billing-Address</ejb-relation-name>
      <!-- first half of relationship, Person side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Person-has-BillingAddress
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Person</ejb-name>
      </relationship-role-source>
      <cmr-field><cmr-field-name>billingAddress</cmr-field-name></cmr-field>
      </ejb-relationship-role>
      <!-- second half of relationship, Address side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      BillingAddress-of-Person
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>Address</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      </ejb-jar>

      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>
      <enterprise-beans>

      <ejb-name>Sequence</ejb-name>
      <table-name>SEQUENCES</table-name>
      <cmp-field>
      <field-name>index</field-name>
      <column-name>SEQUENCECOUNTER</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>name</field-name>
      <column-name>SEQUENCENAME</column-name>
      </cmp-field>


      <ejb-name>Address</ejb-name>
      <table-name>ADDRESS</table-name>
      <cmp-field>
      <field-name>addressId</field-name>
      <column-name>ADDRESSID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>addressOne</field-name>
      <column-name>ADDRESSONE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>addressTwo</field-name>
      <column-name>ADDRESSTWO</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      <column-name>CITY</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>state</field-name>
      <column-name>STATE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>zipcode</field-name>
      <column-name>ZIPCODE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>country</field-name>
      <column-name>COUNTRY</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>phoneNumber</field-name>
      <column-name>PHONE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>extension</field-name>
      <column-name>EXTENSION</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>faxNumber</field-name>
      <column-name>FAX</column-name>
      </cmp-field>


      <ejb-name>Login</ejb-name>
      <table-name>LOGINS</table-name>
      <cmp-field>
      <field-name>loginId</field-name>
      <column-name>LOGINID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>company</field-name>
      <column-name>COMPANYID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>userStrId</field-name>
      <column-name>USERSTRID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>password</field-name>
      <column-name>PASSWORD</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>salt</field-name>
      <column-name>SALT</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>hintQuestion</field-name>
      <column-name>HINTQUESTION</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>hintAnswer</field-name>
      <column-name>HINTANSWER</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>hintSalt</field-name>
      <column-name>HINTSALT</column-name>
      </cmp-field>


      <ejb-name>Person</ejb-name>
      <table-name>PERSONS</table-name>
      <cmp-field>
      <field-name>personId</field-name>
      <column-name>PERSONID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>roleId</field-name>
      <column-name>ROLEID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      <column-name>FIRSTNAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>middleInitial</field-name>
      <column-name>MI</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>title</field-name>
      <column-name>TITLE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>homePhone</field-name>
      <column-name>HOMEPHONE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>emailAddr</field-name>
      <column-name>EMAILADDR</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>address</field-name>
      <column-name>ADDRESSID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>shipAddress</field-name>
      <column-name>SHIPPINGADDRESSID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>billAddress</field-name>
      <column-name>BILLINGADDRESSID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>birthDate</field-name>
      <column-name>BIRTHDATE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>gender</field-name>
      <column-name>GENDER</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>signupDate</field-name>
      <column-name>SIGNUPDATE</column-name>
      </cmp-field>


      <ejb-name>Company</ejb-name>
      <table-name>COMPANIES</table-name>
      <cmp-field>
      <field-name>companyId</field-name>
      <column-name>COMPANYID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>businessName</field-name>
      <column-name>BUSINESSNAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>contactPerson</field-name>
      <column-name>CONTACTID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>address</field-name>
      <column-name>ADDRESSID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>offercodeId</field-name>
      <column-name>OFFERCODEID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>signupDate</field-name>
      <column-name>SIGNUPDATE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>terminationDate</field-name>
      <column-name>TERMINATIONDATE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>terminationReason</field-name>
      <column-name>TerminationReason</column-name>
      </cmp-field>


      <ejb-name>User</ejb-name>
      <table-name>USERS</table-name>
      <cmp-field>
      <field-name>person</field-name>
      <column-name>PERSONID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>login</field-name>
      <column-name>LOGINID</column-name>
      </cmp-field>

      </enterprise-beans>

      <ejb-relation>
      <ejb-relation-name>Login-Company</ejb-relation-name>
      <foreign-key-mapping/>
      <!-- first half of relationship, Login side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Login-to-Company
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>company</field-name>
      <column-name>CompanyId</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <!-- second half of relationship, Company side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Company-has-login
      </ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>User-Login</ejb-relation-name>
      <foreign-key-mapping/>
      <!-- first half of relationship, User side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      User-has-Login
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>login</field-name>
      <column-name>LoginId</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <!-- second half of relationship, Login side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Login-for-User
      </ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Company-Address</ejb-relation-name>
      <foreign-key-mapping/>
      <!-- first half of relationship, Company side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Company-has-Address
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>address</field-name>
      <column-name>AddressId</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <!-- second half of relationship, Address side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Address-for-Company
      </ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Company-Person</ejb-relation-name>
      <foreign-key-mapping/>
      <!-- first half of relationship, User side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Company-has-Contact-Person-or-User
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>contactPerson</field-name>
      <column-name>ContactId</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <!-- second half of relationship, Person side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Contact-Person-or-User-of-Company
      </ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Person-Address</ejb-relation-name>
      <foreign-key-mapping/>
      <!-- first half of relationship, Person side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Person-has-Address
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>address</field-name>
      <column-name>AddressId</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <!-- second half of relationship, Address side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Address-of-Person
      </ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Person-Shipping-Address</ejb-relation-name>
      <foreign-key-mapping/>
      <!-- first half of relationship, Person side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Person-has-ShippingAddress
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>shippingAddress</field-name>
      <column-name>ShippingAddressId</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <!-- second half of relationship, Address side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      ShippingAddress-of-Person
      </ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation>
      <ejb-relation-name>Person-Billing-Address</ejb-relation-name>
      <foreign-key-mapping/>
      <!-- first half of relationship, Person side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Person-has-BillingAddress
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>billingAddress</field-name>
      <column-name>BillingAddressId</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <!-- second half of relationship, Address side -->
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      BillingAddress-of-Person
      </ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      </ejb-relation>

      </jbosscmp-jdbc>

      Thank You.

      Sundeep

        • 1. Re: CMP field for key not found: field name=company
          Dain Sundstrom Master

          This is way too much stuff to read. Just post the one relationship mapping that is not working. Also wrap the stuff with [ code ][ /code ] tags.

          My guess is you have the key-fields backwards. Switch the side and it will start working.

          • 2. Re: CMP field for key not found: field name=company
            Sundeep Kadakia Newbie

            Hi dsundtrom,
            As you suggested, here is the relationship which do not work. It would be great help if you can help me resolve this problem. Do you think that, CMR/CMF field names accessing the same column name here.

            Thanks a lot.

            Sundeep

            ejb-jar.xml ==>



            <ejb-name>Login</ejb-name>
            <local-home>com.atindiamall.ejb.login.LoginHome</local-home>
            com.atindiamall.ejb.login.Login
            <ejb-class>com.atindiamall.ejb.login.LoginBean</ejb-class>
            <prim-key-class>java.lang.Integer</prim-key-class>
            Flase
            <persistence-type>Container</persistence-type>
            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>Logins</abstract-schema-name>
            <cmp-field><field-name>loginId</field-name></cmp-field>
            <cmp-field><field-name>company</field-name></cmp-field>
            <cmp-field><field-name>userStrId</field-name></cmp-field>
            <cmp-field><field-name>password</field-name></cmp-field>
            <cmp-field><field-name>salt</field-name></cmp-field>
            <cmp-field><field-name>hintQuestion</field-name></cmp-field>
            <cmp-field><field-name>hintAnswer</field-name></cmp-field>
            <cmp-field><field-name>hintSalt</field-name></cmp-field>
            <primkey-field>loginId</primkey-field>
            <transaction-type>Container</transaction-type>


            <query-method>
            <method-name>findByUserStrId</method-name>
            <method-params>
            <method-param>java.lang.String</method-param>
            </method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(a) FROM Logins a WHERE a.userStrId = ?1]]>
            </ejb-ql>




            <ejb-name>Company</ejb-name>
            <local-home>com.atindiamall.ejb.biz.CompanyHome</local-home>
            com.atindiamall.ejb.biz.Company
            <ejb-class>com.atindiamall.ejb.biz.CompanyBean</ejb-class>
            <prim-key-class>java.lang.Integer</prim-key-class>
            False
            <persistence-type>Container</persistence-type>
            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>Companies</abstract-schema-name>
            <cmp-field><field-name>companyId</field-name></cmp-field>
            <cmp-field><field-name>businessName</field-name></cmp-field>
            <cmp-field><field-name>contactPerson</field-name></cmp-field>
            <cmp-field><field-name>address</field-name></cmp-field>
            <cmp-field><field-name>offercodeId</field-name></cmp-field >
            <cmp-field><field-name>signupDate</field-name></cmp-field>
            <cmp-field><field-name>terminationDate</field-name></cmp-field>
            <cmp-field><field-name>terminationReason</field-name></cmp-field>
            <primkey-field>companyId</primkey-field>
            <transaction-type>Container</transaction-type>



            jbosscmp-jdbc.xml =>


            <ejb-name>Login</ejb-name>
            <table-name>LOGINS</table-name>
            <cmp-field>
            <field-name>loginId</field-name>
            <column-name>LOGINID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>company</field-name>
            <column-name>COMPANYID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>userStrId</field-name>
            <column-name>USERSTRID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>password</field-name>
            <column-name>PASSWORD</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>salt</field-name>
            <column-name>SALT</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>hintQuestion</field-name>
            <column-name>HINTQUESTION</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>hintAnswer</field-name>
            <column-name>HINTANSWER</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>hintSalt</field-name>
            <column-name>HINTSALT</column-name>
            </cmp-field>



            <ejb-name>Company</ejb-name>
            <table-name>COMPANIES</table-name>
            <cmp-field>
            <field-name>companyId</field-name>
            <column-name>COMPANYID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>businessName</field-name>
            <column-name>BUSINESSNAME</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>contactPerson</field-name>
            <column-name>CONTACTID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>address</field-name>
            <column-name>ADDRESSID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>offercodeId</field-name>
            <column-name>OFFERCODEID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>signupDate</field-name>
            <column-name>SIGNUPDATE</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>terminationDate</field-name>
            <column-name>TERMINATIONDATE</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>terminationReason</field-name>
            <column-name>TerminationReason</column-name>
            </cmp-field>


            <ejb-relation>
            <ejb-relation-name>Login-Company</ejb-relation-name>
            <foreign-key-mapping/>
            <!-- first half of relationship, Login side -->
            <ejb-relationship-role>
            <ejb-relationship-role-name>
            Login-to-Company
            </ejb-relationship-role-name>
            <key-fields>
            <key-field>
            <field-name>company</field-name>
            <column-name>CompanyId</column-name>
            </key-field>
            </key-fields>
            </ejb-relationship-role>
            <!-- second half of relationship, Company side -->
            <ejb-relationship-role>
            <ejb-relationship-role-name>
            Company-has-login
            </ejb-relationship-role-name>
            <key-fields/>
            </ejb-relationship-role>
            </ejb-relation>



            • 3. Re: CMP field for key not found: field name=company
              Dain Sundstrom Master

              You have company when you should have companyID. As I said before, I think you have the keys on the wrong side. Also you are going to have a hard time getting anything to work if you break name elements across lines. For example, you have the following:

               &lt;ejb-relationship-role-name&gt;
               Login-to-Company
               &lt;/ejb-relationship-role-name&gt;

              White space is included when matching names. This is the way XML works.

              • 4. Re: CMP field for key not found: field name=company
                Sundeep Kadakia Newbie

                Dear dsundstrom,

                I took a little longer to apply your suggestions but when I was done it worked like a charm. You were right about the keys were defined in wrong place. You have saved a lot of my time with very useful suggestions.

                Thank you very much for your help.

                Sundeep Kadakia