1 Reply Latest reply on Apr 25, 2006 6:20 PM by cyril.joui

    CMP field for key not found:when create a cmr relationship

    dpkoolin

      I am creating a CMR relationship b/w two entity bean(one to one bidirectional).There are two entity bean(DepartmenEntity & second is EmployeeEntity).In department primary key is employeeid & this key as a foreign key in employee table.I am trying to create a CMR relationshipb/w these two beans.I have aleady define these tags
      1.CMR relation name
      2.cmr field name
      3.target role name
      4.target entity bean
      5.& othere tag is @jboss.relation fk-column related-pk-field

      after genrating xdoclet this tag
      <key-filed>
      <field-name>employeeID
      EmployeeID</key-filed>
      </key-filed>


      <key-filed>
      <field-name>employee_ID
      Employee_ID</key-filed>
      </key-filed>

      in two different relationship tag.

      After deployment I am getting this error
      org.jboss.deployment.DeploymentException: CMP field for key not found:
      PL> field name=employee
      PL> at
      PL>
      org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.loadKey
      Fields(JDBCRe
      PL> lationshipRoleMetaData.java:374)
      PL> at
      PL>
      org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.init(JD
      BCRelationshi
      PL> pRoleMetaData.java:157)
      PL> at
      PL>
      org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationMetaData.(JDBCRela
      tionMetaData.
      PL> java:308)
      PL> at
      PL>
      org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.(JDBCA
      pplicationMet
      PL> aData.java:383)
      PL> at
      PL>
      org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLo
      ader.java:75)

      PL> at
      PL>
      org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCS
      toreManager.j
      PL> ava:677)
      PL> at
      PL>
      org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreMa
      nager.java:38
      PL> 9)
      PL> at
      PL>
      org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:
      339)
      PL> at
      PL>
      org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java
      :198)
      PL> at org.jboss.ejb.EntityContainer.start(EntityContainer.java:376)
      PL> at org.jboss.ejb.Container.invoke(Container.java:793)
      PL> at
      org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
      PL> at
      PL> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
      PL> at
      PL>
      org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.jav
      a:950)
      PL> at $Proxy6.start(Unknown Source)
      PL> at
      PL> org.jboss.system.ServiceController.start(ServiceController.java:384)
      PL> at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
      PL> at
      PL>
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
      .java:25)
      PL> at java.lang.reflect.Method.invoke(Method.java:324)
      PL> at
      PL>
      org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispat
      cher.java:284
      PL> )
      PL> at
      PL> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
      PL> at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
      PL> at $Proxy224.start(Unknown Source)
      PL> at org.jboss.ejb.EjbModule.startService(EjbModule.java:440)
      PL> at
      PL> org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:164)
      PL> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      PL> at
      PL>
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
      )
      PL> at
      PL>
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
      .java:25)
      PL> at java.lang.reflect.Method.invoke(Method.java


      I have already searched all links they suggest to chnage the tag @jboss.relation to @jboss.target relation but after this this key filed tag removed.If anybody has any idea of this error or a full example of genrating CMT then plz send it to me on bhupendra.yaduvenshi@gmail.com.

      Thanx in advance.


        • 1. Re: CMP field for key not found:when create a cmr relationsh

          Hello,

          I had the same problem.
          This is my example : (User <-> Address)

          In UserBean :

          ...
           /**
           * @ejb.interface-method
           * view-type="local"
           *
           * @ejb.relation
           * name="user-address"
           * role-name="User-has-one-Address"
           * target-ejb="Address"
           * target-role-name="Address-has-one-user"
           * target-multiple="false"
           *
           * @jboss.target-relation
           * related-pk-field="userId"
           * fk-column="user_home_fk_id"
           * fk-constraint="true"
           *
           * @jboss.relation
           * related-pk-field="addressId"
           * fk-column="address_home_fk_id"
           * fk-constraint="true"
           *
           * @return
           */
           public abstract AddressLocal getAddress();
          ...
          


          I just use unidirectionnal relation with my oneToOne.
          userId is the primary key of User
          addressId is the primary key for Address

          Does JBoss create a new table between address and user for you ? (Does anyone know if I can use a foreign key directly in my ADDRESS table ?).

          I hope it will help you.