7 Replies Latest reply on May 19, 2004 5:37 PM by John Anderson

    java.lang.ClassCastException

    ignacio cuesta Newbie

      Hi,
      I've 2 beans one-one relationships
      and this piece of code

      InitialContext ctx = new InitialContext();
      SDocuments myBean = getHome().create();
      Collection col = myBean.getAllDocumentByCategoryId(11);
      Iterator iter = col.iterator();
      while (iter.hasNext()) {
      EDocuments element = ((EDocuments) iter.next());
      System.out.println("Abstract:" + element.getShortabstract());
      EDocMetaData metaData = element.getDocMetaData(); System.out.println("Rawtext:" + metaData.getRawtext());
      }
      } catch (NamingException e) {
      e.printStackTrace();
      }

      in the bold line this error appear:
      java.lang.ClassCastException at com.Entrieva.Skyline.EntityBeans.EDocumentsCMP$Proxy.getDocMetaData()


      the ejb-jar relationships is :
      <!-- Relationships -->

      <ejb-relation >
      <ejb-relation-name>EDocuments-EDocMetaData</ejb-relation-name>

      <ejb-relationship-role >
      <ejb-relationship-role-name>EDocuments-has-one-EDocMetadata</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>EDocuments</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>docMetaData</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role >
      <ejb-relationship-role-name>EDocMetadata-has-one-EDocuments</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>EDocMetaData</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>documents</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      </ejb-relation>