2 Replies Latest reply on Jun 30, 2002 6:43 PM by Michael FF

    CMR ClassCastException

    Michael FF Newbie

      hi,
      My CMR issue doesn't quite match the others listed here so could some one help me out with this. I'm trying to do a simple test to set an address on a user but I when I call the setter I get a ClassCasEtxception.
      I'm using xdoclet to generate my files

      // code that throws the exception below
      User user = userHome.findByPrimaryKey(userPK);
      Address address = addressHome.findByPrimaryKey(addressPK);
      user.setContactAddress(address);


      // portion of the deployment decripter
      <ejb-relation >
      <ejb-relation-name>user-contact-address</ejb-relation-name>
      <!-- unidirectional -->
      <ejb-relationship-role >
      <ejb-relationship-role-name>one-user-has-one-contact-address</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>User</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>contactAddress</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role >
      <ejb-relationship-role-name>contact-address-belongs-to-user</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>Address</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>


      //the methods in my entity bean user
      /**
      *
      * @ejb:interface-method
      * @ejb:relation
      * name="user-contact-address"
      * role-name="one-user-has-one-contact-address"
      * target-ejb="Address"
      * target-role-name="contact-address-belongs-to-user"
      * @jboss:relation
      * fk-column="contact_addr_id_fk"
      * related-pk-field="id"
      */
      public abstract com.artstopia.user.interfaces.Address getContactAddress();

      /**
      * @ejb:interface-method
      */
      public abstract void setContactAddress(com.artstopia.user.interfaces.Address a);





      // exception recieved
      2002-06-29 22:17:10,263 INFO [STDOUT] 22:17:10,257 ERROR [LogInterceptor] TransactionRolledbackException, causedBy:
      java.lang.ClassCastException: $Proxy156
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JDBCCMRFieldBridge.java:624)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setValue(JDBCCMRFieldBridge.java:563)
      at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:125)
      at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
      at com.artstopia.user.ejb.UserCMP$Proxy.setContactAddress()
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1197)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:190)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:340)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:193)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:273)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.Container.invoke(Container.java:705)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)


      any help would be greatly appreaciated.
      thanks
      Mike