0 Replies Latest reply on Mar 2, 2004 2:20 PM by marekss

    EJB relation - exception in DBCCMRFieldBridge.setInstanceVal

    marekss Newbie

      Hi all,

      I would llike to ask you for help. I have a problem with setting the relation - there are 2 entity beans with ONE to MANY relationship (see ejb-jar.xml). When I try to set SenavigatorLink on Senavigator (using Collection) I get the following exception :



      20:07:48,311 ERROR [STDERR] javax.ejb.EJBException: null; CausedByException is:
      null
      20:07:48,311 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JDBCCMRFieldBridge.java:673)
      20:07:48,311 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setValue(JDBCCMRFieldBridge.java:541)
      20:07:48,321 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:126)
      20:07:48,321 ERROR [STDERR] at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
      20:07:48,321 ERROR [STDERR] at testrelation.SenavigatorBean$Proxy.setSenavigatorlinks()
      20:07:48,321 ERROR [STDERR] at testrelation.SenavigatorBean.setLink(SenavigatorBean.java:93)
      20:07:48,321 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      20:07:48,321 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)


      This exception is thrown by this portion of code in setInstanceValue method of JDBCCMRFieldBridge :

      try
      {
      // Remove old value(s)
      List valuesCopy = new ArrayList(fieldState.getValue());
      Iterator relatedKeys = valuesCopy.iterator();
      while(relatedKeys.hasNext())
      destroyRelationLinks(myCtx, relatedKeys.next());

      // Add new value(s)
      if(newPkValues != null)
      {
      for(Iterator iter = newPkValues.iterator(); iter.hasNext();)
      createRelationLinks(myCtx, iter.next());
      }
      else
      {
      while(newBeans.hasNext())
      {
      EJBLocalObject newBean = (EJBLocalObject)newBeans.next();
      createRelationLinks(myCtx, newBean.getPrimaryKey());
      }
      }
      }
      catch(EJBException e)
      {
      throw e;
      }
      catch(Exception e)
      {
      throw new EJBException(e);
      }

      But I really do not know the right reason of that exception (with null argument???). Please, if you have any idea I would appreciate it. Thanks a lot.

      Cheers
      Mark




      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">
      <ejb-jar id="ejb-jar_ID">
      <display-name>Treloation</display-name>
      <enterprise-beans>

      <display-name>Senavigator</display-name>
      <ejb-name>Senavigator</ejb-name>
      testrelation.SenavigatorHome
      testrelation.Senavigator

      <ejb-class>testrelation.SenavigatorBean</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>Senavigator</abstract-schema-name>

      <cmp-field id="CMPAttribute_1078145935263">
      <field-name>senaid</field-name>
      </cmp-field>
      <primkey-field>senaid</primkey-field>

      <ejb-ref>
      <ejb-ref-name>ejb/SenavigatorlinkRef</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      testrelation.SenavigatorlinkHome
      testrelation.Senavigatorlink
      <ejb-link>Senavigatorlink</ejb-link>
      </ejb-ref>




      <display-name>Senavigatorlink</display-name>
      <ejb-name>Senavigatorlink</ejb-name>
      testrelation.SenavigatorlinkHome
      testrelation.Senavigatorlink
      <ejb-class>testrelation.SenavigatorlinkBean</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>Senavigatorlink</abstract-schema-name>

      <cmp-field id="CMPAttribute_1078145935724">
      <field-name>senalid</field-name>
      </cmp-field>
      <primkey-field>senalid</primkey-field>

      </enterprise-beans>


      <ejb-relation id="Relationships_1078145947491">
      <ejb-relation-name>senavigator-senavigatorlink</ejb-relation-name>

      <ejb-relationship-role id="EJBRelationshipRole_1078145947451">
      senavigator
      <ejb-relationship-role-name>SenavigatorRelationshipRole</ejb-relationship-role-name>
      One
      <relationship-role-source>
      senavigator
      <ejb-name>Senavigator</ejb-name>
      </relationship-role-source>
      <cmr-field>
      senavigatorlinks
      <cmr-field-name>senavigatorlinks</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role id="EJBRelationshipRole_1078145947481">
      senavigatorlink
      <ejb-relationship-role-name>SenavigatorlinkRelationshipRole</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      senavigatorlink
      <ejb-name>Senavigatorlink</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>

      </ejb-relation>

      <assembly-descriptor>
      <container-transaction id="MethodTransaction_1078145935674">

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

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction id="MethodTransaction_1078145935994">

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

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