2 Replies Latest reply on Jan 15, 2006 2:44 PM by Dennis Meyer

    CMP field for key not found

    snavjot Newbie

      Hi,

      I have 2 beans PurchaseOrderItem and Product that has the relation as defined below in the DD. When i deploy, this exception gets thrown.

      ========== Exception =====================
      16:51:03,017 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()'
      Cause: Incomplete Deployment listing:
      Packages waiting for a deployer:

      Incompletely deployed packages:

      MBeans waiting for classes:

      MBeans waiting for other MBeans:
      [ObjectName: jboss.j2ee:jndiName=ejb/PurchaseOrderHome,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Role 'PurchaseOrderItem-Has-Product' on Entity Bean 'PurchaseOrderItem' : CMP field for key not found: field name='prodCode', ObjectName: jboss.j2ee:jndiName=ejb/CustomerProfileHome,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Role 'PurchaseOrderItem-Has-Product' on Entity Bean 'PurchaseOrderItem' : CMP field for key not found: field name='prodCode', ObjectName: jboss.j2ee:jndiName=ejb/CustomerLoginHome,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Role 'PurchaseOrderItem-Has-Product' on Entity Bean 'PurchaseOrderItem' : CMP field for key not found: field name='prodCode', ObjectName: jboss.j2ee:jndiName=ejb/PurchaseOrderItemHome,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Role 'PurchaseOrderItem-Has-Product' on Entity Bean 'PurchaseOrderItem' : CMP field for key not found: field name='prodCode', ObjectName: jboss.j2ee:jndiName=ejb/ProductHome,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Role 'PurchaseOrderItem-Has-Product' on Entity Bean 'PurchaseOrderItem' : CMP field for key not found: field name='prodCode', ObjectName: jboss.j2ee:jndiName=ejb/CategoryHome,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Role 'PurchaseOrderItem-Has-Product' on Entity Bean 'PurchaseOrderItem' : CMP field for key not found: field name='prodCode']
      ========== Exception =====================

      I am sure many have might have faced this problem. i searched a lot and tried but couldn't get thru this problem.

      Please help on this. Seems like i am digging the same hole deeper but actually i need to dig a new hole but where??

      regards
      Navjot Singh
      Jboss 3.2.3

      ======= ejb-jar.xml relevant parts =============


      <![CDATA[PurchaseOrderItem EJB]]>
      <display-name>PurchaseOrderItem</display-name>
      <ejb-name>PurchaseOrderItem</ejb-name> com.fuzzylabz.order.interfaces.PurchaseOrderItemHome
      com.fuzzylabz.order.interfaces.PurchaseOrderItem <local-home>com.fuzzylabz.order.interfaces.PurchaseOrderItemLocalHome</local-home> com.fuzzylabz.order.interfaces.PurchaseOrderItemLocal <ejb-class>com.fuzzylabz.order.ejb.PurchaseOrderItemCMP</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>PurchaseOrderItem</abstract-schema-name>
      <cmp-field >
      <![CDATA[Gets the key of this order item]]>
      <field-name>poItemId</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Gets the quantity bought of this product]]>
      <field-name>quantity</field-name>
      </cmp-field>
      <primkey-field>poItemId</primkey-field>

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



      <![CDATA[Product EJB]]>
      <display-name>Product</display-name>

      <ejb-name>Product</ejb-name>

      com.fuzzylabz.product.interfaces.ProductHome
      com.fuzzylabz.product.interfaces.Product
      <local-home>com.fuzzylabz.product.interfaces.ProductLocalHome</local-home>
      com.fuzzylabz.product.interfaces.ProductLocal

      <ejb-class>com.fuzzylabz.product.ejb.ProductCMP</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>Product</abstract-schema-name>
      <cmp-field >
      <![CDATA[Returns the prodCode]]>
      <field-name>prodCode</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the name]]>
      <field-name>name</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the description]]>
      <field-name>description</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the unitPrice]]>
      <field-name>unitPrice</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the discountPercent]]>
      <field-name>discountPercent</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Returns the sellOnline]]>
      <field-name>sellOnline</field-name>
      </cmp-field>
      <primkey-field>prodCode</primkey-field>


      <query-method>
      <method-name>findAll</method-name>
      <method-params>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[SELECT OBJECT(p) FROM Product AS p]]></ejb-ql>




      ======== jboss.xml relevant parts ============


      <ejb-name>PurchaseOrderItem</ejb-name>
      <jndi-name>ejb/PurchaseOrderItemHome</jndi-name>
      <local-jndi-name>ejb/PurchaseOrderItemLocalHome</local-jndi-name>

      <method-attributes>
      </method-attributes>



      <ejb-name>Product</ejb-name>
      <jndi-name>ejb/ProductHome</jndi-name>
      <local-jndi-name>ejb/ProductLocalHome</local-jndi-name>

      <method-attributes>
      </method-attributes>



      ======== jbosscmp-jdbc.xml relevant parts ============


      <ejb-name>Product</ejb-name>

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

      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>varchar(20)</sql-type>

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

      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>varchar(50)</sql-type>

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

      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>varchar(100)</sql-type>

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

      <jdbc-type>DOUBLE</jdbc-type>
      <sql-type>double</sql-type>

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

      <jdbc-type>DOUBLE</jdbc-type>
      <sql-type>double</sql-type>

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

      </cmp-field>




      <ejb-name>PurchaseOrderItem</ejb-name>

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

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

      </cmp-field>



      <ejb-relation>
      <ejb-relation-name>PurchaseOrderItem-Product</ejb-relation-name>

      <ejb-relationship-role>
      <ejb-relationship-role-name>PurchaseOrderItem-Has-Product</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>prodCode</field-name>
      <column-name>prod_fk</column-name>
      </key-field>
      </key-fields>

      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Product-BelongsTo-PuchaseOrderItem</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields/>

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

        • 1. Re: CMP field for key not found
          snavjot Newbie

          Greetings,

          I know i couldn't expect any reply to this kind of problem.

          Anyway, i sat down and started digging out. I had to create the entire ER diagram and compare it with ejb-jar.xml, jbosscmp-jdbc.xml. Everything seemed to be allright in first go. But then, by luck, i struck to a point where i have a wrong relation between totally different entities. Customer and CustomerProfile. That was the problem for this error.

          if anyone faces this problem, i will advise not to look at the error staright away but also start backtracking to the source relations.

          HTH
          Navjot Singh

          • 2. Re: CMP field for key not found
            Dennis Meyer Newbie

            That was a good hint! Netbeans also generates the wrong primary key. Although I knew it, I just went over that and didn't think about it when searching for the cause.

            THX!