ClassCastException, Cayenne 2.0.4

From: Ian Boston (ianbosto..ooglemail.com)
Date: Fri Sep 05 2008 - 13:37:04 EDT

  • Next message: Andrus Adamchik: "Re: ClassCastException, Cayenne 2.0.4"

    Hi,

    Has anyone seen the exception below before ?

    I have traced the code and found that:

    in the AbstractCollectionProperty which is a ToManyListProperty
    the accessor is a property called "person"
    and the owner.objectClass is a DbAddress

    DbAddress does have a toMany property called "person" which connects
    to DbPerson

    However the DbPerson does not implement a ValueHolder (hence the
    classcast exception).
    DbAddress also 2 other 1 to many relationships (ie its shared).

    and DbAddress does not have any setPerson(List<DbPerson> x) methods
    or any properties that relate to person.
    DbPerson does have a setAddresses (note the plural)

    -------------------------------------------------

    The code that generates the failure is https://
    source.sakaiproject.org/contrib/tfd/trunk/social-db/
    and the test class that causes it is DbSmallTest.java

    Other DbAddress objects have been saved to the DB and this is on a
    query of an address object as you will see from the
    PersonPopulate.getNewAddress() entry point

    I did look through the lists but couldn't find anything, so any
    pointers would be most helpful (I am certain its something I am doing
    wrong)

    Thanks
    Ian

    java.lang.ClassCastException:
    org.apache.shindig.social.opensocial.model.db.DbPerson
            at
    org.apache.cayenne.property.AbstractCollectionProperty.ensureCollectionV
    alueHolderSet(AbstractCollectionProperty.java:123)
            at
    org.apache.cayenne.property.AbstractCollectionProperty.injectValueHolder
    (AbstractCollectionProperty.java:106)
            at org.apache.cayenne.property.BaseClassDescriptor.injectValueHolders
    (BaseClassDescriptor.java:182)
            at org.apache.cayenne.access.DataContext.localObject
    (DataContext.java:1897)
            at org.apache.cayenne.access.ObjectResolver.objectFromDataRow
    (ObjectResolver.java:199)
            at org.apache.cayenne.access.ObjectResolver.objectsFromDataRows
    (ObjectResolver.java:117)
            at
    org.apache.cayenne.access.ObjectResolver.synchronizedObjectsFromDataRows
    (ObjectResolver.java:97)
            at
    org.apache.cayenne.access.DataDomainQueryAction.interceptObjectConversio
    n(DataDomainQueryAction.java:319)
            at org.apache.cayenne.access.DataDomainQueryAction.execute
    (DataDomainQueryAction.java:116)
            at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:746)
            at org.apache.cayenne.util.ObjectContextQueryAction.runQuery
    (ObjectContextQueryAction.java:217)
            at org.apache.cayenne.access.DataContextQueryAction.execute
    (DataContextQueryAction.java:54)
            at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1395)
            at org.apache.cayenne.access.DataContext.performQuery
    (DataContext.java:1384)
            at
    org.apache.shindig.social.opensocial.db.test.PersonPopulate.getNewAddres
    s(PersonPopulate.java:336)
            at
    org.apache.shindig.social.opensocial.db.test.PersonPopulate.createPerson
    (PersonPopulate.java:63)
            at
    org.apache.shindig.social.opensocial.db.test.DbSmallTest.loadBuildDb
    (DbSmallTest.java:98)
            at
    org.apache.shindig.social.opensocial.db.test.DbSmallTest.testSimpleQueri
    es(DbSmallTest.java:72)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke
    (NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke
    (DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at junit.framework.TestCase.runTest(TestCase.java:168)
            at junit.framework.TestCase.runBare(TestCase.java:134)
            at junit.framework.TestResult$1.protect(TestResult.java:110)
            at junit.framework.TestResult.runProtected(TestResult.java:128)
            at junit.framework.TestResult.run(TestResult.java:113)
            at junit.framework.TestCase.run(TestCase.java:124)
            at junit.framework.TestSuite.runTest(TestSuite.java:232)
            at junit.framework.TestSuite.run(TestSuite.java:227)
            at org.junit.internal.runners.JUnit38ClassRunner.run
    (JUnit38ClassRunner.java:81)
            at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run
    (JUnit4TestReference.java:38)
            at org.eclipse.jdt.internal.junit.runner.TestExecution.run
    (TestExecution.java:38)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
    (RemoteTestRunner.java:460)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
    (RemoteTestRunner.java:673)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
    (RemoteTestRunner.java:386)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
    (RemoteTestRunner.java:196)



    This archive was generated by hypermail 2.0.0 : Fri Sep 05 2008 - 13:37:49 EDT